让我们阅读文档:
在同一进程中运行多个蜘蛛
默认情况下,当您运行时,Scrapy会为每个进程运行一个蜘蛛
scrapycrawl。但是,Scrapy支持使用内部API在每个进程中运行多个蜘蛛。这是一个同时运行多个蜘蛛的示例:
import scrapyfrom scrapy.crawler import CrawlerProcessclass MySpider1(scrapy.Spider): # Your first spider definition ...class MySpider2(scrapy.Spider): # Your second spider definition ...process = CrawlerProcess()process.crawl(MySpider1)process.crawl(MySpider2)process.start() # the script will block here until all crawling jobs are finished
(文档中没有更多示例)
从您的问题还不清楚您如何将两个蜘蛛放在一个文件中。仅用单个蜘蛛连接两个文件的内容是不够的。
尝试执行文档中写的内容。或者至少向我们显示您的代码。没有它,我们将无法为您提供帮助。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)