如何向另一个具有不同设置的蜘蛛产生 Scrapy 请求?

How to yield a Scrapy Request to another spider with different settings?

这个问题和Pass scraped URL's from one spider to another本质上是一样的,但是我想仔细检查一下是否没有'Scrapy-native'的方法。

我正在抓取 99% 的网页,无需渲染即可成功抓取 JavaScript。然而,有时这会失败并且某些 Field 不存在。我想写一个Scrapy Extension with an item_scraped method which checks if all expected fields are populated and if not, yield a SplashRequest to a different spider with custom_settings including the Splash settings (cf. https://blog.scrapinghub.com/2015/03/02/handling-javascript-in-scrapy-with-splash/).

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

启用scrapy-splash只会让SplashRequest生效,不会影响常规scrapy.Request(如果request.meta中没有'splash')。

您可以包含 Splash 设置并且仍然会产生 scrapy.Request - 它们将在没有 Splash 的情况下进行处理。