0
我正在學習scrapy,因爲某些原因它只返回頁面上的第一項。有人能告訴我我做錯了什麼嗎?scrapy返回第一項
下面是我的代碼:
class RuvillaSpider(Spider):
name = "RuvillaSpider"
allowded_domains = ["ruvilla.com"]
start_urls = ["https://www.ruvilla.com/men/footwear.html?dir=desc&limit=45&order=news_from_date"]
def parse(self, response):
products = Selector(response).xpath('//div[@class="category-products"]')
if not products:
raise CloseSpider('RuvillaSpider: DONE, NO MORE PAGES.')
for product in products:
item = RuvillaItem()
item['name'] = product.xpath('ul/li/div/div[1]/a/@title').extract()[0]
item['link'] = product.xpath('ul/li/div/div[1]/a/@href').extract()[0]
item['image'] = product.xpath('ul/li/div/div[1]/a/img/@src').extract()[0]
yield item
這裏,除了定義你的類,你是*先驗*沒有任何錯誤。你對這個類的實例做什麼也可能是有幫助的。例如,這可能會告訴我們您意識到您正在使用發電機。 – Kanak