python-3.x - Scrapy 一次运行所有蜘蛛。我只想一次运行一只蜘蛛。 Scrapy crawl <spider>

标签 python-3.x web-scraping scrapy

我是 Scrapy 的新手,正在尝试使用该框架。真正令人沮丧的是,当我运行“scrapy crawl(蜘蛛名称)”时,它会运行“蜘蛛”文件夹中的每一个蜘蛛。所以我要么必须等待所有运行的蜘蛛,要么注释掉所有蜘蛛,除了我正在使用的蜘蛛。这很烦人。我怎样才能让scrapy一次只运行一只蜘蛛?

最佳答案

您可以从脚本( https://scrapy.readthedocs.io/en/latest/topics/practices.html#run-from-script )运行scrapy,
例如:

import scrapy
from scrapy.crawler import CrawlerProcess

class YourSpider(scrapy.Spider):
    # Your spider definition


process = CrawlerProcess()
process.crawl(YourSpider)
process.start() 

关于python-3.x - Scrapy 一次运行所有蜘蛛。我只想一次运行一只蜘蛛。 Scrapy crawl <spider>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58573755/

相关文章:

python - Pandas 使用 for 循环连接数据帧

php - 如何抓取网站内容(*复杂* iframe,javascript 提交)

python - 将 Scrapy 指向本地缓存而不是执行正常的爬取过程

python - 扁平字典和嵌套字典之间的速度性能差异

python - 没有 math.sqrt 的数字的平方根

Python 在没有 shell=false 和数组中的变量的情况下使用子进程时出错

c# - 如何将 python 数据结构返回给 C#

python - 调用 Python 文件后 Excel CSV 输出出现错误

python - 从 csv 文件读取 start_urls

selenium - 在scrapy中推迟部分抓取