Metadata-Version: 2.4
Name: py-tor-runner
Version: 1.0.1
Summary: A Python utility for managing Tor processes to enable anonymous web browsing through SOCKS5 proxies.
Author: Tobias Würth
License-Expression: Unlicense
Project-URL: Repository, https://github.com/tobiaswuerth/tor-runner
Project-URL: Bug Tracker, https://github.com/tobiaswuerth/tor-runner/issues
Keywords: python,tor,proxy,SOCKS5
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# tor-runner

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

## Installation

Requires local [Tor Browser](https://www.torproject.org/download/) to be installed.

```bash
pip install py-tor-runner
```

`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
```python
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

```python
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()
```
