【发布时间】:2015-12-14 06:20:17
【问题描述】:
试图阅读 Scrapy 的代码。 scaper、crawler 和 spider 这三个词令人困惑。例如
scrapy.core.scraper
scrapy.crawler
scrapy.spiders
谁能在 Scrapy 的上下文中解释这些术语的含义和区别?提前致谢。
【问题讨论】:
标签: web-crawler scrapy scrapy-spider
试图阅读 Scrapy 的代码。 scaper、crawler 和 spider 这三个词令人困惑。例如
scrapy.core.scraper
scrapy.crawler
scrapy.spiders
谁能在 Scrapy 的上下文中解释这些术语的含义和区别?提前致谢。
【问题讨论】:
标签: web-crawler scrapy scrapy-spider
Crawler (scrapy.crawler) 是 Scrapy API 的主要入口点。它提供对所有 Scrapy 核心组件的访问,并用于将扩展功能挂钩到 Scrapy。
Scraper (scrapy.core.scraper) 组件负责解析响应并从中提取信息。它从引擎运行,并用于运行您的蜘蛛。
scrapy.spiders 是一个包含基本 Spider 实现(用于编写蜘蛛)的模块,以及一些开箱即用的常见蜘蛛(如基于规则集的 CrawlSpider抓取,SitemapSpider 用于基于站点地图的抓取,或 XMLFeedSpider 用于抓取 XML 提要)。
更多信息请参见官方文档页面:
http://doc.scrapy.org/en/latest/topics/spiders.html?highlight=crawlspider#spiders
http://doc.scrapy.org/en/latest/topics/api.html?highlight=scrapy.crawler#module-scrapy.crawler
【讨论】: