Skip to content

Instantly share code, notes, and snippets.

@pilgrim2go
Forked from iammehrabalam/tor-python-request
Created November 22, 2017 09:27
Show Gist options
  • Save pilgrim2go/dd6dc65a2855bd966f306ae6f92c1969 to your computer and use it in GitHub Desktop.
Save pilgrim2go/dd6dc65a2855bd966f306ae6f92c1969 to your computer and use it in GitHub Desktop.
sudo apt-get install tor
# check tor service running on port 9050 (ss -aln | grep 9050)
# change ip after every 10 sec
edit vi /etc/tor/torrc and add MaxCircuitDirtiness 10
# use tor proxy in python request
install requests==2.10.0 (pip install requests==2.10.0) (currently 2.11 giving error)
install pysocks (pip install pysocks)
import requests
proxy={'http': 'socks5://localhost:9050'}
print requests.get('http://icanhazip.com', proxies=proxy).text
###############
##export all_proxy=socks://127.0.0.1:9050
##export ALL_PROXY=http://127.0.0.1:9050
##export http_proxy=socks://127.0.0.1:9050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment