我有一个简单的代码,使用代理提交" GET"要求谷歌。
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
我使用的是有效的代理,但这个模块不起作用,有人知道为什么会这样吗?
答案 0 :(得分:0)
Win Error 10060
表示无法建立连接,并且主机或连接(代理)出错。由于谷歌几乎从未停止过,我们可以将问题缩小到代理配置范围。
由于您似乎正确配置了代理(假设您传递了正确的类型和arugments),您可能需要检查服务器还支持哪种SOCKS协议。
要么您没有将有效值作为代理配置传递,要么是服务器的错误。
您还可以尝试使用wireshark进行诊断,以查看是否有任何数据包甚至可以将其发送到服务器。