python用代理服务器访问https网站可以,访问http网站就不行了

时间:2025-02-07 19:51:17
代码如下:
import
url=“http://218.92.191.43:38093
proxy_support=({‘http’:‘49.83.220.45:1080’})
opener=.build_opener(proxy_support)
=[(‘User-Agent’,‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER’)]
#.install_opener(opener)
try:
res=(url)
except as reason:
print(“访问出错为:”+str(reason))
else:
html=().decode(“utf-8”)
print(html)
运行结果:访问出错为:<urlopen error [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。>
后来尝试将proxy_support=({‘http’:‘49.83.220.45:1080’})中的http改成https就可以爬取了,这是什么鬼!
结果测试根本没有用代理服务器爬取而是用本机ip进行爬取