lnky
lnky

Reputation: 13

KeyError: 'Spider not found:

I am following the youtube video https://youtu.be/s4jtkzHhLzY and have reached 13:45, when the creator runs his spider. I have followed the tutorial precisely, yet my code refuses to run. This is my actual code. I imported scrapy too as well. Can anyone help me figure out why scrap refuses to acknowledge my spider? The file is in the correct 'spider' file. I am so confused rn.

import scrapy
from scrapy.spiders import Spider
class WhiskeySpider(scrapy.Spider):
   spider_name = 'whiskey'
   start_urls = ['https://www.whiskyshop.com/single-malt-scotch-whisky']

   def parse(self, response):
        for products in response.css('div.product-item-info'):
            yield {
                'name' : products.css('a.product-item-link::text').get(),
                'price' : products.css('span.price::text').get().replace('£',''),
                'link' : products.css('a.product-item-link').attrib['href'],
            }

Photo of my code in VSC

Upvotes: 1

Views: 1898

Answers (3)

simonz simonzi
simonz simonzi

Reputation: 1

your spider file name is: "whiskeyspider", but with regards to the error:'Spider not found: whiskey'; it seems that you ran : scrapy crawl whiskey

I think you should run: scrapy crawl whiskeyspider

Upvotes: 0

lnky
lnky

Reputation: 13

The solution that I found was to first, change spider_name to name, and also include my scrapy project inside the venv folder, so that the venv terminal would affect my spider. Thanks so much to @SuperUser and @Tim Roberts for the help.

Upvotes: 0

SuperUser
SuperUser

Reputation: 4822

spider_name = 'whiskey' should be name = 'whiskey'

Upvotes: 0

Related Questions