我的剧本有些问题。 它应该通过一个代理打开一个网站,但我总是会遇到这个错误,我试图用几个代理。。。
可能是什么?
Traceback (most recent call last):
File "C:\Users\Shady\Desktop\ptzplace.3.0 - Copy.py", line 43, in <module>
h = urllib.urlopen(website, proxies = {'http': proxy})
File "C:\Python26\lib\urllib.py", line 86, in urlopen
return opener.open(url)
File "C:\Python26\lib\urllib.py", line 200, in open
return self.open_unknown_proxy(proxy, fullurl, data)
File "C:\Python26\lib\urllib.py", line 219, in open_unknown_proxy
raise IOError, ('url error', 'invalid proxy for %s' % type, proxy)
IOError: [Errno url error] invalid proxy for http: 'xxx.xxx.xxx.xxx'
剧本是这样的
proxylist = ['79.174.195.84:80',
'79.174.195.82:80',
'80.233.184.227:8080',
'79.174.195.80:80',
'80.233.184.226:8080',
'79.174.33.95:3128']
for proxy in proxylist:
h = urllib.urlopen(website, proxies = {'http': proxy})
我和你的proxylist一起尝试下一个代码,但是它太长了,所以我得到了其他代理:p
我相信您需要在每个代理之前使用http模式标识符:
尝试
urllib2.urlopen
,而不是urllib.urlopen
。我曾经遇到过这样的情况:代理服务器上的urllib.urlopen
阻塞,但是urllib2.urlopen
可以很好地打开它。相关问题 更多 >
编程相关推荐