June, 2020

To make requests over Tor using Python3, we are going to be utilizing a Python controller library for Tor called Stem.

In order to do so, you need to install the stem package for your OS.

However, you’re not done yet. You might get this error :

It’s because Port 9051 is not open on your machine yet.

To fix this issue, you’ll need to edit your torrc file and uncomment the corresponding lines.

ControlPort 9051 # # If you enable the controlport, be sure to enable one of these # # authentication methods, to prevent attackers from accessing it. HashedControlPassword16:<your_password>

To generate your password, run :

tor --hash-password "<new_password>"

where <new_password>

is the password that you want to set.

And you’re done with Making Requests over Tor.

Note: To run the tor commands, you need to have tor package installed. For macOS, it can be easily installed using

brew install tor

Previously published at https://dev.to/arthtyagi/how-to-make-requests-over-tor-58ep