Python3.2:urllib、SSL和TOR-through-socket:error with fileno函数
我有一个错误,当我尝试用下面的代码通过socksipy连接https时 我在这里举了一个例子: 或者这个: 编辑:当我使用HTTP时,这段代码实际上是有效的,但不适用于HTTPS 我已经从Socksipy python模块导入了socks 代码如下: 调用方法:Python3.2:urllib、SSL和TOR-through-socket:error with fileno函数,python,sockets,ssl,urllib,tor,Python,Sockets,Ssl,Urllib,Tor,我有一个错误,当我尝试用下面的代码通过socksipy连接https时 我在这里举了一个例子: 或者这个: 编辑:当我使用HTTP时,这段代码实际上是有效的,但不适用于HTTPS 我已经从Socksipy python模块导入了socks 代码如下: 调用方法: googleAdr = "https://173.194.65.94" pageSocket = getURL( googleAdr ) pageHtml = pageSocket.read() pageSocket.close() p
googleAdr = "https://173.194.65.94"
pageSocket = getURL( googleAdr )
pageHtml = pageSocket.read()
pageSocket.close()
page = BeautifulSoup( pageHtml )
print(" Page calendar :" + page .prettify() )
错误如下:
你有什么想法吗?即使是坏的?
多谢各位 你能展示一下你导入了哪些模块吗?什么是袜子(没有定义)我已经编辑了问题中的代码。socks库来自pythonthink的Socksipy模块,它仅适用于HTTP代理。看看,您可以尝试使用
ssl
包装它。当然,您需要调整您的功能,以满足HTTP和HTTPSIs的需要h@ckssl文件,模块,通过添加缺少的函数fileno?我已经尝试过了,但我不知道该如何填充此函数。如果使用ssl
包装连接,会有好运吗?我用python2.7进行了测试,它是有效的
googleAdr = "https://173.194.65.94"
pageSocket = getURL( googleAdr )
pageHtml = pageSocket.read()
pageSocket.close()
page = BeautifulSoup( pageHtml )
print(" Page calendar :" + page .prettify() )
File "/home/turf/connectSafe.py", line 101, in getURL
resp = urllib.request.urlopen(req)
File "/usr/lib/python3.2/urllib/request.py", line 139, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.2/urllib/request.py", line 370, in open
response = self._open(req, data)
File "/usr/lib/python3.2/urllib/request.py", line 388, in _open
'_open', req)
File "/usr/lib/python3.2/urllib/request.py", line 348, in _call_chain
result = func(*args)
File "/usr/lib/python3.2/urllib/request.py", line 1176, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.2/urllib/request.py", line 1140, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/usr/lib/python3.2/http/client.py", line 970, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.2/http/client.py", line 1008, in _send_request
self.endheaders(body)
File "/usr/lib/python3.2/http/client.py", line 966, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.2/http/client.py", line 811, in _send_output
self.send(msg)
File "/usr/lib/python3.2/http/client.py", line 749, in send
self.connect()
File "/usr/lib/python3.2/http/client.py", line 1111, in connect
server_hostname=server_hostname)
File "/usr/lib/python3.2/ssl.py", line 189, in wrap_socket
_context=self)
File "/usr/lib/python3.2/ssl.py", line 243, in __init__
fileno=sock.fileno()
TypeError: __init__() got an unexpected keyword argument 'fileno'