[Python] TOR With Python Tutorial #1 - Connecting to TOR
Why Stack Overflow recommends it
Stack Overflow users cite it as the walkthrough they followed to send Python requests through Tor, usually when asking why the setup fails or how to toggle the proxy.
Recommended by 2 people across 2 different months, 2014 to 2015.
What it is
A short 2012 Python 2 tutorial by AcuteGaming showing how to route a Python script's network traffic through Tor using the SocksiPy module and a local SOCKS5 proxy on port 9050. It is the first video in a series on using Tor from Python.
What people said
Recommends kilgoretrout · 2015-09 · Stack Overflow · on “Python - Toggling a connection to my local SOCKS proxy”
I am writing a crawler in Python that will run through Tor. I have Tor working and used code from this YouTube tutorial [this video] on how to route my Python requests to go through the Tor SOCKS proxy at 127.0.0.1:9050 . What I can't figure out is how to toggle this on/off within my script. Some requests I want to go through Tor and some I don't. Basically, I can't figure out the correct "close" or "shutdown" method in the socket objects I am using because I don't understand them. Here's what happens now import socket import socks import requests def connect_to_socks(): socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 9050, True) socket.socket = socks.socksocket r = requests.get(' [LI
Recommends cwahls · 2015-12 · Stack Overflow · on “Python: intercative program like arm-tor”
What you could do is use msvcrt.getch() to get pages (1,2,3,4). You could then have different funcions or scripts that rendered each page. There are some videos here [this video] that explain how the connections work, but nothing as interactive as I explained. If you need more help, reply.
Cites Cingonius Varro · 2014-01 · Stack Overflow · on “SocksiPy fails when connecting throug Tor”
Tried the 3 following methods to control Tor: using TorCtl/urllib2: Python script Exception with Tor [LINK] using socks/httplib: [this video] using socks/urllib2: Python urllib over TOR? [LINK] Each of them fails w/ same error (tried to make it as clear as possible): Traceback (most recent call last): File "tor.py", line 26, in <module> print(urllib2.urlopen(" [LINK] ").read()) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py" line 127, in urlopen return _opener.open(url, data, timeout) line 404, in open response = self._open(req, data) line 422, in _open '_open', req) line 382, in _call_chain result = func(*args) line 1214, in http_open return self.do_open(httplib
Cites Milano · 2015-06 · Stack Overflow · on “Connecting via TOR raises error”
I'm having trouble with connecting to the Internet via TOR. I've followed all instructions from this [this video] youtube video but I'm still getting error: Connected to Tor # printed string Traceback (most recent call last): .... .... File "C:\Python27\lib\httplib.py", line 787, in connect self.timeout, self.source_address) File "C:\Python27\lib\socket.py", line 571, in create_connection raise err socket.error: [Errno 10061] No connection could be made because the target machine actively refused it I'm attaching the code: import httplib import socket import socks port = 9050 url = 'my-ip.heroku.com' def connectTor(): socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", port, True) socket.