问题标签 [scrapy-splash]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
245 浏览

scrapy - Scrapy-splash 无法加载网站

我想通过 scrapy-splash抓取一个网站( http://www.adl.com.tr/en/c/cengiz-abazoglu-koleksiyonu-4 )。但无法加载使用 javascript 制作的项目。我尝试将 splash.wait(0.5) 增加到 (10) 并启用 DOWNLOAD_DELAY=5。没有改变。

你有什么建议吗?

Splash 渲染网站的屏幕截图

0 投票
1 回答
2103 浏览

python-3.x - Scrapy-Splash 会话处理

我一直在尝试登录一个网站,然后抓取一些只有在登录后才能访问的网址。

我正在按照Session Handling中的说明进行操作。首先,我登录并开始重定向到主页,这已正确保存在login.html中(登录正常)。然后我获取cookie并将它们设置在第二个SplashRequest中进行搜索,但是search_result.html中的响应是用户未登录。为了在不同的SplashRequest中保持会话,我错过了什么或做错了什么?

问候,

0 投票
0 回答
415 浏览

web-scraping - Scrapy 从 ASP.NET 站点下载 zip 文件

我需要一些帮助才能从 asp.net 站点下载文件。通常从浏览器中,单击链接并开始下载文件,但对于scrapy来说这是不可能的,所以我想做的是以下内容:

我正在尝试将信息提交到页面,以便接收 zip 文件作为响应,但是这并没有像我希望的那样工作。相反,我只是得到与响应相同的页面。

在这种情况下甚至可以使用scrapy来下载这个文件吗?有人有任何指示吗?

我也尝试过使用 Selenium+PhantomJS,但我在尝试将会话从 scrapy 转移到 selenium 时遇到了死胡同。我愿意为这个功能使用 selenium,但我需要在这个项目中使用 scrapy。

0 投票
1 回答
1727 浏览

python - "500 Internal Server Error" when combining Scrapy over Splash with an HTTP proxy

I'm trying to crawl a Scrapy spider in a Docker container using both Splash (to render JavaScript) and Tor through Privoxy (to provide anonymity). Here is the docker-compose.yml I'm using to this end:

where the Scraper has the following Dockerfile:

and the spider I'm trying to crawl is

where I've added the following to settings.py:

With the environment for the scraper container commented out, the Scraper more-or-less works. I get logs containing the following:

However, if I comment in the environment lines in the docker-compose.yml, I get a 500 Internal Server Error:

In short, when using Splash to render JavaScript, I'm not able to successfully use the HttpProxyMiddleware in order to also use Tor through Privoxy. Can someone see what is going wrong here?

Update

Following Paul's comment, I tried adapting the splash service as follows:

where I've added a 'splash' directory to the main directory like so:

and proxy.ini reads

As I understand it, this should make the proxy be used always (i.e. the whitelist defaults to ".*" and no blacklist).

However, if I again docker-compose build and docker-compose up, I still get HTTP 500 errors. So the question remains how to solve these?

(Incidentally, this question seems similar to https://github.com/scrapy-plugins/scrapy-splash/issues/117; however, I'm not using Crawlera so I'm not sure how to adapt the answer).

Update 2

Following Paul's second comment, I checked that tor-privoxy resolves within the container by doing this (while it was still running):

As for how I'm running Splash, it's through a linked container, similar to the way described in https://splash.readthedocs.io/en/stable/install.html#docker-folder-sharing. I've verified that the /etc/splash/proxy-profiles/proxy.ini is present in the container:

I will try Aquarium, but the question remains why the current setup doesn't work?

0 投票
1 回答
1155 浏览

python - Scrapy-Splash 如何实现代理配置文件?

我在将 Scrapy-Splash 与 HTTP 代理一起使用时遇到了一些问题(请参阅将 Scrapy over Splash 与 HTTP 代理结合使用时的“500 Internal Server Error”),即使我尝试在http://splash之后设置代理配置文件也是如此.readthedocs.io/en/latest/api.html#proxy-profiles

为了更好地了解发生了什么,我一直在寻找 Scrapy-Splash 源代码的一部分,https://github.com/scrapy-plugins/scrapy-splash,它解析代理hostport.ini文件中指定/etc/splash/proxy-profiles.

但是,在存储库中搜索“proxy”或“.ini”没有产生任何结果。有人可以向我解释一下代理分析是如何在 Scrapy-Splash 中实现的吗?

0 投票
1 回答
1611 浏览

javascript - 使用 Scrapy-splash 导航动态页面

背景:我正在使用 Scrapy 从http://shop.nordstrom.com/c/mens-tshirts. 该页面是动态生成的,所以我使用 Scrapy-Splash 来处理 JavaScript。问题是,点击页面底部的“下一步”按钮是进入后续产品页面的唯一途径。如果您复制第 2 页的 url 并将其粘贴到新选项卡中,则该页面上没有产品。

为了解决这个问题,我尝试使用.click()Selenium 中的功能导航到下一页,并driver.page_source提取页面的 html。

问题:有没有办法将我提取的 html/javascript 源代码传递给 Splash(在 docker 容器内运行),而不是传入 url?我尝试将 html 保存在本地计算机上并传递文件路径,但这会导致 502 Bad Gateway,因为 Splash 会自动在路径前添加“http://”。

也许有更好的方法可以在这里实现我的目标,如果是这样,我愿意接受任何选择。请记住,该解决方案必须适合可扩展性和云部署。谢谢!

0 投票
1 回答
6865 浏览

python - Scrapy Splash 截图?

我正在尝试抓取一个网站,同时对每个页面进行截图。到目前为止,我已经设法拼凑出以下代码:

它可以很好地进入站点(例如stackoverflow)并返回png_bytes的数据,但是当写入文件时-返回损坏的图像(不加载)。

有没有办法解决这个问题,或者找到更有效的解决方案?我读过 Splash Lua Scripts 可以做到这一点,但一直无法找到实现这一点的方法。谢谢。

0 投票
1 回答
922 浏览

scrapy - 通过 Scrapy-Splash 返回图像内容

我正在使用 Scrapy-Splash 请求来获取页面的渲染屏幕截图,但我还需要该页面上的图像。我使用管道下载这些图像,但我在想 - 这不会对同一个图像提出两个请求吗?一次是在 Splash 呈现页面时,一次是在我发送下载请求时。有没有办法获得 Scrapy-Splash 请求返回的图像?

0 投票
0 回答
1026 浏览

javascript - 带有 Scrapy 的 Docker Splash 无法正常工作

我正在尝试抓取一个使用 scrapy-splash 插件启用了 javascript 的网站。

我已经使用 docker 安装了 splash 和这些命令我使用的是Ubuntu 16.04

我有正在运行的splash docker就像一切看起来都很好但是

处理scrapy错误时,splash会抛出此错误

我认为这部分可能是问题所在

而且该网站是一个 HTTPS 网站

在剪贴画中

我在scrapy中导入了这样的scrapy- splash

我正在提出这样的要求

代替

但像往常一样,飞溅没有处理请求

我在这里做错了什么?Ubuntu有什么问题吗?

抓取调试输出

0 投票
1 回答
345 浏览

python - 如何向具有不同设置的另一个蜘蛛发出 Scrapy 请求?

这个问题本质上与将抓取的 URL 从一个蜘蛛传递到另一个蜘蛛相同,但我想仔细检查是否没有“Scrapy-native”方法来做到这一点。

我正在抓取 99% 的时间可以在不渲染 JavaScript 的情况下成功抓取的网页。然而,有时这会失败并且某些Fields 不存在。我想用一种方法编写一个 Scrapy扩展item_scraped,该方法检查是否填充了所有预期的字段,如果没有,则生成一个包含 Splash 设置SplashRequest的不同蜘蛛(参见https://blog.scrapinghub.com/2015/ 03/02/handling-javascript-in-scrapy-with-splash/)。custom_settings

是否有任何 Scrapy 方法可以在不使用外部服务(如 Redis)的情况下做到这一点?