Does anyone know how I can run multiple spiders subsequently within a Python file that calls Scrapy at some stage? At the moment my code is breaking because I think the next spider is being blocked because the first one is running.
if __name__ == "__main__":
c = CrawlerProcess({
'USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
'FEED_FORMAT': 'json',
'FEED_URI': 'spider_one.json'
})
c.crawl(SpiderOneSpider)
c.start() #the script will block here until the crawling is finished according to the documentation
c = CrawlerProcess({
'USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
'FEED_FORMAT': 'json',
'FEED_URI': 'spider_two.json'
})
c.crawl(SpiderTwoSpider)
c.start()
Also not sure if there is a neater way to write this code? I'm basically using SpiderTwo to do the same thing SpiderOne does but just exports a different JSON file.