scrapy: Don't require 'name' attribute for scrapy.Spider

I think we should make Spider.name attribute optional. The name is used by SpiderManager to find spiders, but Spider can be used without a Scrapy project. It is unnecessary boilerplate for users of runspider command or for CrawlerRunner / CrawlerProcess users.

We can also provide a default value, e.g. self.__class__.__name__, to help with discovery; this have an advantage of 1-to-1 mapping between spider class names and names printed to users - spiders can become easier to find.

Opinions?

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 1
  • Comments: 16 (15 by maintainers)

Most upvoted comments

If and when this is done, please take into account that Spidermon currently uses spider names, for example to generate unique, spider-specific filenames for storing data in disk. You can search for spider.name there to find some of those usages.

Any change in this direction in Scrapy should probably be accompanied by the corresponding change in Spidermon.

other 3rd party libs that also can use spider.name. Here mentioned spidermon

If Scrapy adds a default property name for the scenario where the user doesn’t define a name attribute, probably it won’t require any changes in Spidermon. Is there a PR for this change so I can run it and test in Spidermon?