Pet*_* K. 2 python twisted scrapy docker scrapy-splash
我在 Javascript 驱动的网站上使用 scrapy 和splash。但是,我无法传递Connection was refused by other side: 10061错误。
我得到这样的日志:
[scrapy.downloadermiddlewares.retry] DEBUG: Retrying
<GET https://www2.deloitte.com/ch/en/misc/search.html#country=All#qr=accounting
via http://localhost:8050/render.html> (failed 1 times): Connection
was refused by other side: 10061: No connection could be made because
the target machine actively refused it..
Run Code Online (Sandbox Code Playgroud)
和指向扭曲的回溯:
twisted.internet.error.ConnectionRefusedError: Connection was refused
by other side: 10061: No connection could be made because the target
machine actively refused it..
Run Code Online (Sandbox Code Playgroud)
我检查了设置中的所有条目,尝试了各种USER_AGENTS条目ROBOT,但没有运气。也尝试过使用--disable-private-mode启动splash,但没有效果。
奇怪的是,只需将相同的网址复制粘贴到浏览器中就可以正常工作。
我使用普通的命令行 scrapy,以及通过 API。有趣的是,当使用 API 时,当然,在 PyCharm 中单击错误消息中目标的 url,主题标签 # 会被其转义代码替换。所以我很困惑在平视显示器下这是否是另一个问题或者两者是否相关。
甚至尝试查看通过 Wireshark 和 Fiddler 发送的包,但无法很好地理解结果,因为我以前从未使用过这些工具。
任何建议将不胜感激。
最终,成功找出了罪魁祸首。这确实是与 docker 容器的连接。
首先,我必须使用以下命令检索 docker 容器 IP
docker-machine ip
Run Code Online (Sandbox Code Playgroud)
在码头工人终端。接下来,我必须SPLASH_URL在 scrapy settings.py 文件中进行调整以指向 docker-machine ip 而不是localhost:8050,瞧……它起作用了。
不幸的是,到目前为止我所看到的消息来源对此还不清楚,所以我希望这对其他第一次设置飞溅的可怜的灵魂有一些用处。
| 归档时间: |
|
| 查看次数: |
3249 次 |
| 最近记录: |