1

I have made 1 file with 2 spiders/classes. the 2nd spider with use some data from the first one. but it doesn't seem to work. here is what i do to initiate and start the spiders

process=CrawlerProcess()
process.crawl(Zoopy1)
process.crawl(Zoopy2)
process.start()

what do you suggest

Shandy
  • 11
  • 2
  • Welcome! Please, consider this [article](https://stackoverflow.com/help/how-to-ask) first. It's not enough context to tell anything. – rawrex Jun 03 '21 at 12:54

1 Answers1

0

Your code will run 2 spiders simultaneously.
Running spiders sequentially (start Zoopy2 after completion of Zoopy1) can be achieved with @defer.inlineCallbacks:

from twisted.internet import reactor, defer
from scrapy.crawler import CrawlerRunner
from scrapy.utils.log import configure_logging
...

configure_logging()
runner = CrawlerRunner()

@defer.inlineCallbacks
def crawl():
    yield runner.crawl(Zoopy1)
    yield runner.crawl(Zoopy2)
    reactor.stop()

crawl()
reactor.run()

Alternative option (if it is suitable for Your task) - is to merge logic from 2 spiders into single spider Class,

Georgiy
  • 3,158
  • 1
  • 6
  • 18