tor.py (531B)
1 import requests 2 import time 3 import logging 4 5 import config 6 7 time.sleep(3) 8 9 if config.tor_proxy is None: 10 config.tor_proxy = "127.0.0.1:9050" 11 12 logging.info("Using tor proxies {}".format(config.tor_proxy)) 13 session = requests.session() 14 session.proxies = { 15 "http": "socks5h://{}".format(config.tor_proxy), 16 "https": "socks5h://{}".format(config.tor_proxy), 17 } 18 19 logging.info( 20 "Checking tor circuit IP address... You should check this is different to your IP." 21 ) 22 r = session.get("http://httpbin.org/ip") 23 logging.info(r.text)