Я кодировал простого паука для получения информации о кавычках:
import scrapy
class GoodReadsSpider(scrapy.Spider):
#identity
name = 'goodreads'
#requests
def start_requests(self):
url = "https://www.goodreads.com/quotes?page=1",
yield scrapy.Request(url=url, callback= self.parse)
#response
def parse(self, response):
for quote in response.selector.xpath("//div[@class='quote']"):
yield {
'text': quote.xpath(".//blockquote[@class='quoteBody']/text()[1]").extract_first(),
'author': quote.xpath(".//span[@class='quoteAuthor']/text()").extract_first(),
'tag': quote.xpath(".//div[@class='quoteTags']/a/text()").extract(),
}
Когда я запускаю его, я получаю следующую ошибку:
Request url must be str or unicode, got %s:' % type(url).__name__
Кто-нибудь знает почему?