Skip to content

Instantly share code, notes, and snippets.

@gaotongfei
Forked from jefftriplett/tor.py
Created October 26, 2015 09:45
Show Gist options
  • Save gaotongfei/8502f7cb1ac22f7139f8 to your computer and use it in GitHub Desktop.
Save gaotongfei/8502f7cb1ac22f7139f8 to your computer and use it in GitHub Desktop.
Python Requests + Tor (Socks5)
"""
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())
@itJunky
Copy link

itJunky commented Oct 4, 2017

How can i open .onion domains?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment