install and use tor on ubuntu for python requests

Tags: , ,

Install tor on ubuntu:

sudo apt-get install tor

open vi /etc/tor/torrc, set up the ports:

Then start tor:

service tor start

Check tor service

Install stem and PySocks

pip install PySocks
pip install stem

The following is the code to use tor as proxy in python.