1
我用網下代理服務器下代理服務器使用mwclient
self.wp = site if site else mwclient.Site(self.url)
當上面一行遇到下列錯誤顯示
File "C:\Python27\lib\site-packages\mwclient-0.6.5-py2.7.egg\mwclient\client.py", line 92, in __init__
self.site_init()
File "C:\Python27\lib\site-packages\mwclient-0.6.5-py2.7.egg\mwclient\client.py", line 100, in site_init
siprop = 'general|namespaces', uiprop = 'groups|rights')
File "C:\Python27\lib\site-packages\mwclient-0.6.5-py2.7.egg\mwclient\client.py", line 165, in api
info = self.raw_api(action, **kwargs)
File "C:\Python27\lib\site-packages\mwclient-0.6.5-py2.7.egg\mwclient\client.py", line 248, in raw_api
json_data = self.raw_call('api', data).read()
File "C:\Python27\lib\site-packages\mwclient-0.6.5-py2.7.egg\mwclient\client.py", line 223, in raw_call
url, data = data, headers = headers)
File "C:\Python27\lib\site-packages\mwclient-0.6.5-py2.7.egg\mwclient\http.py", line 225, in post
return self.find_connection(host).post(host,
File "C:\Python27\lib\site-packages\mwclient-0.6.5-py2.7.egg\mwclient\http.py", line 218, in find_connection
conn = cls(host, self)
File "C:\Python27\lib\site-packages\mwclient-0.6.5-py2.7.egg\mwclient\http.py", line 62, in __init__
self._conn.connect()
File "C:\Python27\lib\httplib.py", line 757, in connect
self.timeout, self.source_address)
File "C:\Python27\lib\socket.py", line 571, in create_connection
raise err
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
我嘗試使用的urllib2通過以下步驟代理設置,但它沒有幫助
>>> import urllib2
>>> auth = 'http://xxxxx:[email protected]:8080'
>>> handler = urllib2.ProxyHandler({'http':auth})
>>> opener = urllib2.build_opener(handler)
>>> urllib2.install_opener(opener)
你認爲mwclient怎麼知道這個開啓者?我沒有使用mwclient,但看着它的代碼,我認爲它根本就不是urllib2。你能否詳細說明,可能是發佈了更多的代碼 – dusual 2013-03-20 08:17:23
mwclient使用httplib.HTTPConnection功能顯示錯誤原因我沒有代理環境 – Pradyumna 2013-03-20 10:46:32
@perpetual:這是這裏的問題;爲了支持代理,你需要重寫整個'mwclient'代碼庫。它不支持代理服務器。 – 2013-03-20 11:31:40