如何在Jupyter中运行Scrapy项目?

在Mac上,我安装了Jupyter,当我从Scrapy项目的根文件夹中键入jupyter notebook时,它会打开笔记本。 此时我可以浏览所有的项目文件。

我如何从笔记本执行项目?

如果我点击运行选项卡,在终端下,我看到:

There are no terminals running.

有两种主要的方法可以实现这一点:

1.在文件选项卡下,打开一个新终端:新建>终端
然后简单地运行你的蜘蛛: scrapy crawl [options] <spider>

2.创建一个新的笔记本,并使用CrawlerProcessCrawlerRunner类在单元中运行:

from scrapy.crawler import CrawlerProcess
from scrapy.utils.project import get_project_settings

process = CrawlerProcess(get_project_settings())

process.crawl('your-spider')
process.start() # the script will block here until the crawling is finished

Scrapy文档 - 从脚本运行Scrapy

链接地址: http://www.djcxy.com/p/94203.html

上一篇: How to run Scrapy project in Jupyter?

下一篇: Is it possible to write this function in Haskell?