简体   繁体   English

Python请求私有代理身份验证不返回

[英]Python requests private proxy authentication does not return

I'm writing a scraper that will extract information of a given proxy. 我正在写一个抓取器,它将提取给定代理的信息。 I'm using python requests with private proxies having username and password to access " https://ip8.com/ " that will give information about the proxy and will scrape the information. 我正在将python请求与具有用户名和密码的专用代理一起使用,以访问“ https://ip8.com/ ”,该操作将提供有关代理的信息,并将抓取该信息。

Now, the problem is I tried almost everything but the request does not return anything, in fact does not return until timeout. 现在,问题是我几乎尝试了所有操作,但请求不返回任何内容,实际上直到超时才返回。 Proxies are working perfectly fine, so no issues there. 代理工作正常,因此没有问题。

I've tried almost every method. 我尝试了几乎所有方法。 I've tried urllib3 as well, but had no success. 我也尝试过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)

I expect html of the page accessed through the IP to ip8.com 我希望通过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)

The above should work 以上应该工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM