烨子丶 发表于 2021-8-6 20:18:54

urlopen 求助

import urllib.request

url = '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)

求助求助

大马强 发表于 2021-8-7 07:23:02

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)

大马强 发表于 2021-8-7 07:23:34

现在一般用requests用的多
页: [1]
查看完整版本: urlopen 求助