![](/img/trans.png)
[英]Python-requests, HTTPS proxy authentication <407 Proxy Authentication Required>
[英]Python requests private proxy authentication does not return
我正在写一个抓取器,它将提取给定代理的信息。 我正在将python请求与具有用户名和密码的专用代理一起使用,以访问“ https://ip8.com/ ”,该操作将提供有关代理的信息,并将抓取该信息。
现在,问题是我几乎尝试了所有操作,但请求不返回任何内容,实际上直到超时才返回。 代理工作正常,因此没有问题。
我尝试了几乎所有方法。 我也尝试过urllib3
,但没有成功。
import requests
from requests.auth import HTTPProxyAuth
proxy_string = 'http://username:password@proxy:port'
s = requests.Session()
s.proxies = {"http": proxy_string , "https": proxy_string}
s.auth = HTTPProxyAuth("username","password")
r = s.get('https://ip8.com/') # OK
print(r.text)
我希望通过IP访问ip8.com的页面的html
import requests
proxy_string = 'http://username:password@proxy:port'
proxyDict = {"http": proxy_string , "https": proxy_string}
r = requests.get('https://ip8.com/', proxies=proxyDict) # OK
print(r.text)
以上应该工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.