2010-07-07 159 views
3

我在腳本中遇到了一些麻煩。 它應該打開一個網站槽代理,但我總是,這個錯誤,與幾個代理,我試圖...IOError:[Errno網址錯誤] http:'xxx.xxx.xxx.xxx'的無效代理

它可能是什麼?

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}) 

回答

3

我試了下代碼與proxylist但tooks這麼久,所以我得到了其他代理: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() 
+0

嗯...顯然,你的作品...我會嘗試modlease我的使用你的基地... – Shady 2010-07-07 03:49:57

+0

非常奇怪...你的代碼在我的腳本不要工作......真是個地獄 – Shady 2010-07-07 07:58:37

3

我相信你們每個代理之前需要的HTTP模式標識符:

proxylist = ['http://79.174.195.84:80',... 'http://79.174.33.95:3128'] 
+0

我已經試過...相同的東西=/ – Shady 2010-07-07 01:24:47

8

嘗試urllib2.urlopen而不是urllib.urlopen。我的代理服務器上有urllib.urlopen扼流圈,但是urllib2.urlopen打開它很好。