xpath 的string 方法这样写有问题吗?想获取下面所有的文本

https://img3.mukewang.com/5b93daf30001af4408000214.jpg

content=etree(tr_list[i]).xpath('//td[@class="pl20"]/span')[0].xpath('string(.)')

???


智慧大石
浏览 941回答 1
1回答

当年话下

<span> &nbsp;&nbsp;&nbsp;&nbsp;<span>test</span> &nbsp;&nbsp;&nbsp;&nbsp;<span>.pdf</span></span>from&nbsp;lxml&nbsp;import&nbsp;etree html&nbsp;=&nbsp;etree.parse('hello.html') result&nbsp;=&nbsp;html.xpath('//span/span/text()') print(result)运行结果['test',&nbsp;'.pdf']
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python