scrapy:xpath string(.)非常注意问题

xiaoxiao2021-02-27  163

2019 − 07 − 04 来 自 评 论 更 新 : {\orange{2019-07-04来自评论更新:}} 20190704

text() 类型是节点,而string() 是一个函数,所以 string() 不能像 text() 一样添加在节点后面使用。 需要像如下格式: text = select.xpath("string(//div[@span='ct'])").extract_first()


text = selector.xpath('//div[@span="ct"]/string(.)').extract_first() #写成这样是xpath语法错误,而把string(.)单独提出来就可以过 data = selector.xpath('//div[@span="ct"]') text = data.xpath('string(.)').extract_first()
转载请注明原文地址: https://www.6miu.com/read-16065.html

最新回复(0)