4

我已成功使用此链接使用 Tor 运行 Scrapy:http: //pkmishra.github.io/blog/2013/03/18/how-to-run-scrapy-with-TOR-and-multiple-browser-agents-第 1 部分-mac/

但我无法使用 Tor 运行 Splash。

在 Scrapy-settings.py 中,我针对 http_proxy(8123 是 polipo 端口)指向 polipo:

HTTP_PROXY = 'http://127.0.0.1:8123'

在 polipo.config 中,我指向 tor(9150 是 tor 端口):

socksParentProxy = localhost:9150

diskCacheRoot=""

非常适合scrapy。在飞溅中它不起作用。但我不得不说 splash 或 docker 来使用 polipo 为 http_proxy 就像在 scrapy-settings.py 中一样。Docker 应该以某种方式使用 polipo,而 polipo 将直接指向 tor。我怎样才能做到这一点?

我跑飞溅:

sudo docker run -p 5023:5023 -p 8050:8050 -p 80511 scrapinghub/splash

在 etc/default/docker 中,我尝试使用 docker 直接指向 polipo:

export http_proxy='http://127.0.0.1:8123'
Environment="http_proxy=http://127.0.0.1:8123"

但我无法成功。我究竟做错了什么?谢谢 :)

4

1 回答 1

4

你需要

  1. 使 Tor 可以从 Splash Docker 容器中访问;
  2. 告诉 Splash 使用这个 Tor 代理。

对于 (2),您可以使用 Splash代理配置文件或直接设置代理,或者在代理参数中,或者使用request:set_proxysplash:on_request回调 Lua 脚本。例如,如果 Tor 可以从 Splash Docker 容器作为 tor:8123 访问,您可以执行如下请求:

http://<splash-url>:8050/render.html?url=...&proxy=socks5://tor:8123

另外,请查看https://github.com/TeamHG-Memex/aquarium - 它设置了所有这些 - 它设置了“tor”代理配置文件,在另一个 Docker 容器中启动 Tor,并链接这些容器。要在通过 Aquarium 部署的 Splash 中使用 Tor 访问远程网站,您只需将proxy=torGET 参数添加到请求中:

http://<splash-url>:8050/render.html?url=...&proxy=tor
于 2017-07-20T21:18:43.977 回答