Menu Close

How to make requests via tor in Python

First make sure tor is running, with below code, you will construct a proxy session for tor.

import requests

def get_tor_session():
    session = requests.session()
    session.proxies = {'http':  'socks5://', 'https': 'socks5://'}
    return session

Then you can test your session via:

session = get_tor_session()
print('Tor IP')

Leave a Reply

Your email address will not be published.