0
votes

I am trying to learn Scrapy and going through the basic tutorial.I am using Anaconda Navigator. I am working in an environment with scrapy installed. I have inputted the code, but keep getting an error.

Here is the code:

import scrapy


class FirstSpider(scrapy.Spider):
    name = "FirstSpider"

    def start_requests(self):
        urls = [
            'http://quotes.toscrape.com/page/1/',
            'http://quotes.toscrape.com/page/2/',
        ]
        for url in urls:
            yield scrapy.Requests(url=url, callback = self.parse)

    def parse(self, response):
        page = response.url.split("/")[-2]
        filename = "quotes-%.html" % page
        with open(filename, "wb") as f:
            f.write(response.body)
        self.log("saved file %s")% filename

The code runs for a bit. Says it crawled 0 pages. Then DEBUGS: Telnet Console, and then puts out this error,"[scrapy.core.engine] ERROR: Error while obtaining start requests."

The code then runs some more, and puts out another error after, "yield scrapy.Requests(utl=url, callback = self.parse)" that says "AttributeError: Module 'scrapy' has no attribute 'Requests'.

I have re-written the code, and looked for answers. Please help. Thanks!

1

1 Answers

0
votes

You have a typo here:

yield scrapy.Requests(url=url, callback = self.parse)

It's Request and not Requests.