Skip to main content

A simple python library that allows you to forward requests through the tor network

Project description

pyTorReq

A simple library that allows you to run your requests through the tor network

Basic usage:

from pytorreq import PyTorReq

# If you want to use the library on windows, you need to explicitly specify where tor.exe is located.
# Or specify in the system PATH.
torPath = 'tor.exe'
treq = PyTorReq(torPath=torPath)

# If on Linux, then you can not enter anything.
treq = PyTorReq()

# It launch new tor session.
treq.launchTorSession()

response = treq.get('http://ipecho.net/plain')

# Is your new tor ip.
print(response.text)

Installation

pip istall pytorreq

Dependencies

You need tor. On windows you can download tor browser, and somewhere inside the tor browser folder you will need to find tor.exe.

Everything is simpler on Linux, I think that linux users do not need to be told what they need to do) like apt\dnf bla bla bla...

Note

By default, tor session is generated during class initialization. To get a session object, you can directly refer to it.

treq = PyTorReq(torPath=torPath)
tses = treq.session
<requests.sessions.Session object at 0x000001FAF5D77B80>

The library has one method of resetting personality, you can use the one you like best. After applying this method you will receive a new identity tor and a new ip address

treq.getNewTorIdentity()

There is a wrapper around all the required request methods. Just use them as you would with the good old requests module:

# GET
treq.get()
# POST
treq.post()
# PUT
treq.put()
# PATCH
treq.patch()
# DELETE
treq.delete()

There are also methods for working with cookies. You can safely transfer regular cookies from requests there.

# CookieJar obj
treq.getCookieObj()
# CookiesDict
treq.getCookieDict()
# If you need, you can very simply add a new cookie to the current tor session. Accepts a cookie obj
treq.updateTorSessionCookie(cookie)

You can get your tor ip via the following method:

# it will return string with your ip adr
treq.getMyIp() 

Close method.

# It will close the session.
treq.close()

todos

  1. async get/post links.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytorreq-0.2.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

pytorreq-0.2.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file pytorreq-0.2.1.tar.gz.

File metadata

  • Download URL: pytorreq-0.2.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.2.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.2

File hashes

Hashes for pytorreq-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a8ce5f28fec295911b0a7f7b253181b466c0f2a873a5ae9f467c877a906a33be
MD5 46a2fb4cb3105957ec76e590f9ffc221
BLAKE2b-256 fe4ff7650925133f6ea5bb94defbf9bd6060a31cb014ce11a9a77708d8a344b5

See more details on using hashes here.

File details

Details for the file pytorreq-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pytorreq-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.2.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.2

File hashes

Hashes for pytorreq-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 13a562ee3970a13a30f8f72491a40736fe535554c0cd328b5314277cfb62bfd6
MD5 134def282c7345aeb5f182752c1c2292
BLAKE2b-256 6eef81a3753aa6260b0a147745a71d8c9da165633470019ab09a0eca6becc359

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page