-
-
Save llazzaro/b7a4d0c2c485ca80e315 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
setup: | |
pip install requesocks | |
super helpful: | |
http://packetforger.wordpress.com/2013/08/27/pythons-requests-module-with-socks-support-requesocks/ | |
""" | |
import requests | |
import requesocks | |
session = requesocks.session() | |
session.proxies = { | |
'http': 'socks5://127.0.0.1:9150', | |
'https': 'socks5://127.0.0.1:9150' | |
} | |
url = 'http://ifconfig.me/ip' | |
resp = requests.get(url) | |
print 'ip: {}'.format(resp.text.strip()) | |
resp = session.get(url) | |
print 'tor ip: {}'.format(resp.text.strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment