An open API service indexing awesome lists of open source software.

https://github.com/joangq/torpy

Anonymize HTTP requests using Tor & Python.
https://github.com/joangq/torpy

anonymization onion-service proxy tor

Last synced: 8 months ago
JSON representation

Anonymize HTTP requests using Tor & Python.

Awesome Lists containing this project

README

          



Torpy is a custom library for anonymizing HTTP requests using [Tor](https://www.torproject.org/) as a proxy. It provides methods similar to the ones found in the [`requests`](https://www.pypi.org/project/requests) package. The Onion class is actually a wrapper for the `requests.Session` object.

# Requirements:

- **Linux based OS**
- **Tor installed as service**: It can be installed by running the following command in Linux
```console
sudo apt-get install tor
```
- `requests` package with Sockets installed too. You can get it by:
```console
pip install requests[socks]
```
- All the libraries in `src/tor.py`
- Tested in Python 3.8

# Example usage

```python
import tor

# Initialize Onion service
onion = tor.Onion()

# Get TOR session IP
print(onion.get_ip())
# >>> 123.456.78.12 [Example IP, returns actual TOR session IP]

# Make a HTTP GET request to a custom URL
request = onion.get('https://www.wikipedia.org')
print(request.text)
# >>> [The webpage as text]

# Get new identity
onion.renew_identity()
print(onion.get_ip())
# >>> 255.123.45.67 [Example IP, should return a different valid TOR session IP]
```