简体   繁体   中英

scrapy spider name definition and/or restrictions

Using scrapy example that has: spider in *.py coded as

class ArticleSpider(spider):
    name="article"

When I run scrapy check -l or scrapy crawl article I get an error:

    class ArticleSpider(spider):
NameError: name 'spider' is not defined

I changed to Spider , scrapy.spider , etc. and receive the same error. I looked at scrapy.org, etc., for definitions and/or restrictions on (spider) but can not find any. So what causes this error?

The error is not about the Spider name but from the class you inherit from. That being said:

You must inherit from Spider :

from scrapy.spiders import Spider

Then:

class ArticleSpider(Spider):
    name="article"

Please take in account that class names are case sensitive .

If you need more information, please refer to:

http://doc.scrapy.org/en/1.0/topics/spiders.html#scrapy.spiders.Spider

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM