项目作者: lspahija

项目描述 :
Spin up Tor containers and proxy HTTP requests via these tor instances.
高级语言: Kotlin
项目地址: git://github.com/lspahija/torchestrator.git
创建时间: 2021-01-27T21:26:11Z
项目社区:https://github.com/lspahija/torchestrator

开源协议:Apache License 2.0

下载


Torchestrator

Torchestrator can spin up Tor containers and expose ports for proxying HTTP requests via these Tor instances.

The IP address of the exit node of each Tor instance will vary. This is useful for IP address rotation.

To run:

  • set number of Tor containers you wish to spin up with config property tor.containerQuantity in torchestrator/src/main/resources/application.properties
    (default is 10, but can be a much higher number depending on RAM)
  • cd into torchestrator directory and execute ./gradlew bootRun (with JDK 15) or run in an IDE like IntelliJ IDEA
  • get next proxy port with GET localhost:8080/port

Examples

Scraping with Python using Torchestrator as a proxy provider:

  1. import requests
  2. torchestrator_host = "localhost"
  3. tochestrator_port = 8080
  4. torchestrator_api_path = "port"
  5. def fetch_proxy_port():
  6. response = requests.get(f'http://{torchestrator_host}:{tochestrator_port}/{torchestrator_api_path}')
  7. return response.text
  8. def get_using_proxy(url, proxy):
  9. return requests.get(url, proxies={"http": proxy, "https": proxy})
  10. def scrape_using_proxy(url):
  11. proxy_port = fetch_proxy_port()
  12. response = get_using_proxy(url, f'{torchestrator_host}:{proxy_port}')
  13. print(response.text)
  14. scrape_using_proxy("http://icanhazip.com/")

Similarly, a sample Kotlin HTTP client proxying requests via Tor instances can be found in torchestrator/src/main/kotlin/com/alealogic/torchestrator/client/ExampleClient.kt

Find this useful?

Please star this repository! It helps contributors gauge the popularity of the repo and determine how much time to allot to development.