Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Py-Tor provides a simple and convenient way to interact with the Tor network, offering functionalities to renew IP addresses and ensure IP protection. This Python code demonstrates how to utilize the stem and requests libraries to achieve these tasks.

Prerequisites

Installation

To use Py-Tor, open your terminal and navigate to the folder that contains Py-Tor content ::

pip install -r requirements.txt

Example

fromjsonimportdumpsfromservicesimportTorServicewithTorService() astor:
tor.local_ip#! Checking Local IPtor.tor_ip#! Checking Tor IPtor.checking_status#! Checking Tor statustor.renew_tor_ip#! Renew Tor IPtor.tor_ip#! Checking Tor IP again to confirm IP changedtor.checking_status#! Checking Tor status again to confirm using Torresult= {}
#! GET Requestsresponse_get=tor.get('https://httpbin.org/get')
result['GET'] =response_get.json()
#! GET Request with Query Parametersquery_params= {'param1': 'value1', 'param2': 'value2'}
response_query=tor.get('https://httpbin.org/get', params=query_params)
result['QUERY'] =response_query.json()
#! GET Requests with Custom Headersheaders= {'Custom-Header': 'Custom-Value'}
response_header=tor.get('https://httpbin.org/headers', headers=headers)
result['HEADER'] =response_header.json()
#! POST Requestdata= {'key': 'value'}
response_post=tor.post('https://httpbin.org/post', json=data)
result['POST'] =response_post.json()
#! PUT Requestdata= {'updated_key': 'updated_value'}
response_put=tor.put('https://httpbin.org/put', json=data)
result['PUT'] =response_put.json()
#! HEAD Requestresponse_head=tor.head('https://httpbin.org/get')
result['HEAD'] =dict(response_head.headers)
#! OPTIONS Requestresponse_options=tor.options("https://httpbin.org")
result['OPTIONS'] =dict(response_options.headers)
#! DELETE Requestresponse_delete=tor.delete('https://httpbin.org/delete')
result['DELETE'] =response_delete.json()
#! PATCH Requestdata= {'key_to_update': 'new_value'}
response_patch=tor.patch('https://httpbin.org/patch', json=data)
result['PATCH'] =response_patch.json()
#! Testing ONION URL (Facebook onion from https://www.expressvpn.com/blog/best-onion-sites-on-dark-web/)response_onion=tor.get('https://www.facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion/')
result['ONION'] =dict(response_onion.headers)
print(dumps(result, indent=4))

Note

  • It's important to ensure that the path to the Tor executable (tor_path) is accurate for your system or just use the default.
  • This code does not handle Tor updates, potential network errors, or security considerations in a comprehensive manner. It's intended as a basic example to demonstrate the core functionality of interacting with Tor programmatically.

Legal Disclaimer

This was made for educational purposes only, nobody which directly involved in this project is responsible for any damages caused. You are responsible for your actions.

About

Enhance your online privacy with Tor network interaction, featuring IP address renewal and robust protection, and use it as a Tor proxy for HTTP requests.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages