Scrapy spider not found error

后端 未结 21 1993
感情败类
感情败类 2021-02-02 06:58

This is Windows 7 with python 2.7

I have a scrapy project in a directory called caps (this is where scrapy.cfg is)

My spider is located in caps\\caps\\spiders\\c

相关标签:
21条回答
  • 2021-02-02 07:09

    Make sure you have set the "name" property of the spider. Example:

    class campSpider(BaseSpider):
       name = 'campSpider'
    

    Without the name property, the scrapy manager will not be able to find your spider.

    0 讨论(0)
  • 2021-02-02 07:09

    Also make sure that your project is not called scrapy! I made that mistake and renaming it fixed the problem.

    0 讨论(0)
  • 2021-02-02 07:09

    Ahh Yes, you should enter the value of your 'name variable value'.

    I.e.

    import scrapy
    
    class QuoteSpider(scrapy.Spider):
        name = 'quotes'
        start_urls = [
            'http://quotes.toscrape.com/'
        ]
    
        def parse(self, response):
            title = response.css('title').extract()
            yield {'titleText' : title}
    

    So in this case, the name = 'quotes'. Then in your command line you enter: 'scrapy crawl quotes'

    That was my problem.

    0 讨论(0)
  • 2021-02-02 07:10

    Check indentation too, the class for my spider was indented one tab. Somehow that makes the class invalid or something.

    0 讨论(0)
  • 2021-02-02 07:11

    I had the same issue. When i was using "scrapy list" in cmd the command listed the spider name i was getting the error for, in the list, but while i tried to run it with scrapy crawl SpiderName.py, i used to get Scrapy spider not found error. I have used this spider before and everything was fine with it. So i used the secret weapon, i restarted my system and the issue was resolved :D

    0 讨论(0)
  • 2021-02-02 07:13

    Ensure same name attribute is used in the command line for running spider ...

    scrapy crawl

    0 讨论(0)
提交回复
热议问题