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