所以我是新来的,创造了我的第一只蜘蛛。但我发现了输入错误
这个蜘蛛只是从goodreads的第一页中删除引用。它有30个引号,带标签和作者姓名
import scrapy
class Goodreadspider(scrapy.Spider):
name = 'goodreads'
def start_requests(self):
url = ['https://www.goodreads.com/quotes?page=1']
yield scrapy.Request(url=url, callback=self.parse)
def parse(self, parse):
for quote in response.selector.xpath("//div[@class='quote']"):
yield{
'text': quote.xpath("//div[@class='quoteText']/text()[1]").extract_first,
'author': quote.xpath("//div[@class='quoteText']/child::a/text()").extract_first,
'tags': quote.xpath("//div[@class='greyText smallText left']/a/text()").extract()
}
Typeerror<'Request url must be str or unicode, got %s:'
我认为你有这个错误,因为你试图传递一个列表,而不是str或unicode,就像ask by“scrapy.Request”
试试这个:
应该有用
是否尝试删除[]
url = 'https://www.goodreads.com/quotes?page=1'
相关问题 更多 >
编程相关推荐