您的问题可能与此有关:https ://github.com/scrapy-plugins/scrapy-splash/issues/92
简而言之,尝试将其添加到您的解析回调函数中:
def parse_item(self, response):
"""Parse response into item also create new requests."""
page = RescrapItem()
...
yield page
if isinstance(response, (HtmlResponse, SplashTextResponse)):
seen = set()
for n, rule in enumerate(self._rules):
links = [lnk for lnk in rule.link_extractor.extract_links(response)
if lnk not in seen]
if links and rule.process_links:
links = rule.process_links(links)
for link in links:
seen.add(link)
r = SplashRequest(url=link.url, callback=self._response_downloaded,
args=SPLASH_RENDER_ARGS)
r.meta.update(rule=rule, link_text=link.text)
yield rule.process_request(r)
以防万一,您想知道为什么这会同时返回项目和新请求。这是来自文档:https ://doc.scrapy.org/en/latest/topics/spiders.html
在回调函数中,您解析响应(网页)并返回带有提取数据的字典、Item 对象、Request 对象或
这些对象的可迭代对象。这些请求还将包含一个回调(可能相同),然后将由 Scrapy 下载,然后由指定的回调处理它们的响应。