【发布时间】:2019-11-30 17:31:39
【问题描述】:
代码仅获得 1 个 URL 列表然后停止。它应该得到209个项目。为什么只打印一行?
def parse_link(self, response):
# Extract the list of products
results = response.xpath('//li[@class="s-item "]')
# Extract info for each product
for product in results:
name = product.xpath('//*[@class="s-item__link"]').extract_first()[30:124]
yield{
"Name":name,
}
【问题讨论】:
-
没有任何其他信息很难分辨。请分享所有相关代码和数据。请参阅:minimal reproducible example。
-
看起来您正在使用作为生成器语句的 yield。你是通过 for 循环调用这个函数吗?
标签: python xpath hyperlink scrapy href