代理连接失败
向各位大佬求教,以下是源代码和运行后的反应import urllib.request
url = 'http://www.whatismyip.com.tw'
proxy_support = urllib.request.ProxyHandler({'http':'113.194.29.4:9999'})
opener =urllib.request.build_opener(proxy_support)
response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')
print(html)
本帖最后由 1q23w31 于 2020-8-8 16:35 编辑
代理失效了
重新找一个代理
这个代理可用'http':'http://45.115.167.28:80'
import urllib.request
url = 'http://www.whatismyip.com.tw'
proxy_support = urllib.request.ProxyHandler({'http':'http://45.115.167.28:80'})
opener =urllib.request.build_opener(proxy_support)
response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')
print(html)
设置代理要加协议头
页:
[1]