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.
- Host: GitHub
- URL: https://github.com/joangq/torpy
- Owner: joangq
- License: mit
- Created: 2022-09-25T21:02:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-07T21:42:46.000Z (almost 3 years ago)
- Last Synced: 2025-01-11T04:32:44.420Z (9 months ago)
- Topics: anonymization, onion-service, proxy, tor
- Language: Python
- Homepage:
- Size: 138 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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]
```