Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an example that does not run inside a custom command, but runs the Reactor manually and creates a new Crawler <a href="http://doc.scrapy.org/en/latest/topics/practices.html#running-multiple-spiders-in-the-same-process">for each spider</a>:</p> <pre><code>from twisted.internet import reactor from scrapy.crawler import Crawler # scrapy.conf.settings singlton was deprecated last year from scrapy.utils.project import get_project_settings from scrapy import log def setup_crawler(spider_name): crawler = Crawler(settings) crawler.configure() spider = crawler.spiders.create(spider_name) crawler.crawl(spider) crawler.start() log.start() settings = get_project_settings() crawler = Crawler(settings) crawler.configure() for spider_name in crawler.spiders.list(): setup_crawler(spider_name) reactor.run() </code></pre> <p>You will have to design <a href="http://doc.scrapy.org/en/latest/topics/signals.html">some signal system</a> to stop the reactor when all spiders are finished.</p> <p>EDIT: And here is how you can run multiple spiders in a custom command:</p> <pre><code>from scrapy.command import ScrapyCommand from scrapy.utils.project import get_project_settings from scrapy.crawler import Crawler class Command(ScrapyCommand): requires_project = True def syntax(self): return '[options]' def short_desc(self): return 'Runs all of the spiders' def run(self, args, opts): settings = get_project_settings() for spider_name in self.crawler.spiders.list(): crawler = Crawler(settings) crawler.configure() spider = crawler.spiders.create(spider_name) crawler.crawl(spider) crawler.start() self.crawler.start() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload