I have an error while trying to connect to https via socksipy with the code below.
I followed an example here: using tor as a SOCKS5 proxy with python urllib2 or mechanize
Or this one: Python urllib over TOR?
Edit: this code works when I use HTTP, but not with HTTPS
I imported socks from the Python Socksipy module.
Here is the code:
import socks import socket
Call Method:
googleAdr = "https://173.194.65.94" pageSocket = getURL( googleAdr ) pageHtml = pageSocket.read() pageSocket.close() page = BeautifulSoup( pageHtml ) print(" Page calendar :" + page .prettify() )
Here is the error:
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'
Do you have any ideas? even bad? Thank you very much!