Skip to main content

A Python utility for managing Tor processes to enable anonymous web browsing through SOCKS5 proxies.

Project description

tor-runner

A Python utility for managing Tor processes to enable anonymous web browsing through SOCKS5 proxies.

Installation

Requires local Tor Browser to be installed.

requirements.txt is only necessary if you want to run the provided test files. Otherwise, tor-runner is a standalone library compatible with default Python packages.

Basic Usage with Requests

import requests
from tor import TorProxy

with TorProxy("C:/path/to/tor/browser/tor.exe") as proxy:
    proxy_url = proxy.socks_addr  # Returns "socks5://127.0.0.1:{port}"
    
    # Example with requests
    response = requests.get('https://check.torproject.org', proxies={
        'http': proxy_url,
        'https': proxy_url
    })
    print(response.text)

Basic Usage with Playwright

import time
from tor import TorProxy
from playwright.sync_api import sync_playwright

with TorProxy("C:/path/to/tor/browser/tor.exe") as proxy:
    with sync_playwright() as p:
        browser = p.firefox.launch(
            headless=False,
            proxy={"server": proxy.socks_addr}
        )
        
        # Each page has its own IP through the Tor network
        page1 = browser.new_page()
        page1.goto("https://check.torproject.org")
        
        page2 = browser.new_page()
        page2.goto("https://check.torproject.org")
        
        time.sleep(5) # to let you check manually
        browser.close()

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

py_tor_runner-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_tor_runner-1.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file py_tor_runner-1.0.0.tar.gz.

File metadata

  • Download URL: py_tor_runner-1.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for py_tor_runner-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4d19c5849320f81683fadc5832d1076949b891454ca45c8e7bdc5c1615b46239
MD5 d6aa357cea36d65fed7ec4efbbc27488
BLAKE2b-256 f9d32f0e530c372e46254397bc6fd256780f35341a402c4f75995ed9f446682b

See more details on using hashes here.

File details

Details for the file py_tor_runner-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: py_tor_runner-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for py_tor_runner-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e83d973179074d1a9141c7ae91593a63bc7ad060cc4458180733db041b839f29
MD5 834c78d89bf2865f9c6799a6a85f5afe
BLAKE2b-256 9981dd7437421110ce1c09acc0d982482d7f49648192e1aa8ae3a37aaa20bf99

See more details on using hashes here.

Supported by

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