scrapy yield 请求不工作

标签 scrapy scrapy-spider

我写了下面的 scrapy 蜘蛛,但在初始请求后它没有继续爬行过程,尽管我已经 yielded 更多 scrapy.Request 以供 scrapy 遵循.

import regex as re
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import Spider

class myspider(Spider):
name = 'haha'

allowed_domains = ['https://blog.scrapinghub.com/']
start_urls = ['https://blog.scrapinghub.com/']
extractor = LinkExtractor(allow=allowed_domains)

def parse(self, response):
    # To extract all the links on this page
    links_in_page = self.extractor.extract_links(response)

    for link in links_in_page:
        yield scrapy.Request(link.url, callback=self.parse)

最佳答案

allowed_domains 需要是 a list of domains ,而不是 URL 列表。

所以应该是:

allowed_domains = ['blog.scrapinghub.com']

关于scrapy yield 请求不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40035099/

相关文章:

python - 向mysql中插入多条Scrapy数据

python - Scrapy FakeUserAgentError : Error occurred during getting browser

python - 如何用scrapy抓取每个链接的所有内容?

python - Scrapy返回多个项目

python - 在 Scrapy python 中将参数传递给 process.crawl

python - 如何修复scrapy源码测试失败: FifoDiskQueue

python - 通过 scrapy 抓取数据的 unicode 问题

python-2.7 - 在heroku上部署scrapy项目

python - 在没有线程的情况下从另一个文件调用 Scrapy

python - 导入错误 : No module named win32api while using Scrapy