4

in the older version we could get the list of spiders(spider names ) with following code, but in the current version (1.4) I faced with

[py.warnings] WARNING: run-all-spiders.py:17: ScrapyDeprecationWarning: CrawlerRunner.spiders attribute is renamed to CrawlerRunner.spider_loader.
for spider_name in process.spiders.list():
    # list all the available spiders in my project

Use crawler.spiders.list():

>>> for spider_name in crawler.spiders.list():
...     print(spider_name)

How Can I get spiders list (and equivalent class names) in Scrapy?

vezunchik
  • 3,669
  • 3
  • 16
  • 25
Yuseferi
  • 7,931
  • 11
  • 67
  • 103

1 Answers1

18

I'm using this in my utility script for running spiders:

from scrapy import spiderloader
from scrapy.utils import project

settings = project.get_project_settings()
spider_loader = spiderloader.SpiderLoader.from_settings(settings)
spiders = spider_loader.list()
classes = [spider_loader.load(name) for name in spiders]

In you case, it should suffice to rename spiders to spider_loader as suggested by the warning message.

Tomáš Linhart
  • 9,832
  • 1
  • 27
  • 39