Scrapy/跨多个 HTML 标签提取数据

问题描述 投票:0回答:1
xpath scrapy
1个回答
0
投票

要模仿所有文本节点值,只需使用 //text()

response.xpath('//div[@class="whatever3"]/p[2]//text()').extract() 

join 方法会将字符串提取为由空格分隔的单个字符串。

''.join(response.xpath('//div[@class="whatever3"]/p[2]//text()').extract())
© www.soinside.com 2019 - 2024. All rights reserved.