from requests.auth import HTTPProxyAuth
url = ...
timeout = ...
headers = {}
auth = HTTPProxyAuth(user, password)
proxies = {"http": "http://%s:8010/" % host}
if url.startswith("https:"):
url = "http://" + url[8:]
#https 请求需要设置
headers["x-crawlera-use-https"] = "1"
r = requests.get(url,
headers=headers,
proxies=proxies,
timeout=timeout,
auth=auth,
allow_redirects=False)
requests 使用代理验证
最新推荐文章于 2024-08-26 14:01:09 发布