我的脚本有些麻烦 它应该打开一个网站通过代理服务器,但我得到,总是,这个错误,与几个代理,我试图…
会是什么呢?
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})
我用你的代理列表尝试下一个代码,但花了这么长时间,所以我得到了其他代理:P
import urllib website = 'http://www.google.com/' proxylist = ('http://75.101.215.123:9090', 'http://94.198.47.6:3128') connlist = (urllib.urlopen(website, proxies = {'http': proxy}) for proxy in proxylist) for conn in connlist: print conn.read() conn.close()
试试urllib2.urlopen
而不是urllib.urlopen
。 我有我的代理服务器urllib.urlopen
扼流圈的情况下,但urllib2.urlopen
打开罚款。
我相信你需要每个代理之前的http模式标识符:
proxylist = ['http://79.174.195.84:80',... 'http://79.174.33.95:3128']