我正在尝试完成此任务,我有一个 IP,并且我想使用该 IP 发出 HTTP 请求。
假设我有 stackoverflow.com IP (151.101.193.69) 并且我想使用该requests模块使用 python 在网站上发出 HTTP 请求。我写了这段代码
import requests
response = requests.get("http://151.101.193.69:80")
response.text
Run Code Online (Sandbox Code Playgroud)
返回页面的html代码。这样做我得到一个页面,上面写着
Fastly error: unknown domain: 151.101.193.69. Please check that this domain has been added to a service.
Details: cache-mxp19846-MXP
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用 Google IP 执行此操作,则它可以工作并且请求会返回 Google 主页
import requests
response = requests.get("http://216.58.205.174:80")
response.text
Run Code Online (Sandbox Code Playgroud)