|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import urllib.request
#import random
url = 'http://www.66ip.cn//'
#iplist = ['182.46.102.14:9999','169.255.234.166:8080','117.69.12.33:9999']
proxy_support = urllib.request.ProxyHandler({'http':'182.46.102.14:9999'})
opener = urllib.request.build_opener(proxy_support)
opener.addheaders = ['User-Agent','Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/74.0']
urllib.request.install_opener(opener)
response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')
print(html)
---------------------------------------------------错误---------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\ip地址修改.py", line 17, in <module>
response = urllib.request.urlopen(url)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 522, in open
req = meth(req)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1271, in do_request_
for name, value in self.parent.addheaders:
ValueError: too many values to unpack (expected 2)
求大神们帮帮忙
|
|