urlopen 求助
import urllib.requesturl = 'http://www.whatismyip.com.tw'
proxy_support = urllib.request.ProxyHandler({'https':'113.237.3.178:9999'})
opener = urllib.request.build_opener(proxy_support)
opener.addheaders = ('User-Agent',' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36 Edg/92.0.902.62')
urllib.request.install_opener(opener)
response = urllib.request.urlopen(url)
返回了ValueError: too many values to unpack (expected 2)
求助求助 opener.addheaders = [('User-Agent',' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36 Edg/92.0.902.62')]
urllib.request.install_opener(opener)
现在一般用requests用的多
页:
[1]