0
我有一個簡單的代碼,它使用代理向Google提交「GET」請求。在Python中使用代理和httplib2時的超時錯誤
import httplib2
http = httplib2.Http(proxy_info = httplib2.ProxyInfo(proxy_type=3,proxy_host=myProxy, proxy_port=myPort))
resp, content = http.request("http://google.com", "GET")
print(resp)
print(content)
出於某種原因,我得到一個超時錯誤:
resp, content = http.request("http://google.com", "GET")
File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1322, in requ
st
(response, content) = self._request(conn, authority, uri, request_uri, meth
d, body, headers, redirections, cachekey)
File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 1072, in _req
est
(response, content) = self._conn_request(conn, request_uri, method, body, h
aders)
File "C:\Python35\lib\site-packages\httplib2\__init__.py", line 995, in _conn
request
conn.connect()
File "C:\Python35\lib\http\client.py", line 849, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Python35\lib\socket.py", line 711, in create_connection
raise err
File "C:\Python35\lib\socket.py", line 702, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connecte
party did not properly respond after a period of time, or established connecti
n failed because connected host has failed to respond
我使用的是有效的代理,但此模塊不工作,是否有人知道爲什麼會發生?
我使用的代理是有效的,因爲我試圖將它與請求模塊一起使用,並且按預期工作。 通過檢查服務器支持的socks協議,你的意思是什麼? – KaramJaber