di3g0bs0n / torrequests

Wrapper of requests. Allow Tor requests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

torRequests

Wrapper of the requests library that allows to make requests through TOR.

Author: Diego Fernandez

Installation

pip install torrequests

Usage

Simple GET request (default Tor)

from torrequests import Tor

# Default tor value: 127.0.0.1:9150
tor = Tor() 

r = tor.get('http://www.example.com')

if r.status_code == 200:
	print r.text

Advanced POST request (custom Tor)

from torrequests import Tor

tor = Tor(tor_ip='127.0.0.1', tor_port=9999, headers = {"User-Agent":"Mozilla/5.0 Gecko/20100101 Firefox/45.0"}) 

header = {
	"X-Custom-Header": "1"
}

cookie = {
	"SessionID": "123456789"
}

# Request is sent with both headers (User-Agent and X-Custom-Header), and a Cookie (SessionID)
r = tor.post('http://www.example.com', headers=header, cookies=cookie)

if r.status_code == 200:
	print r.text

Check Public IP

from torrequests import Tor

tor = Tor(tor_ip='127.0.0.1', tor_port=9999)

print getPublicIP()

About

Wrapper of requests. Allow Tor requests

License:GNU General Public License v3.0


Languages

Language:Python 100.0%