扫码关注官方订阅号
光阴似箭催人老,日月如移越少年。
没猜错的话用的Scrapy?
sel.xpath() 得到的依旧是一个SelectorList
参看原文档
xpath(query) Find nodes matching the xpath query and return the result as a SelectorList instance with all elements flattened. List elements implement Selector interface too. query is a string containing the XPATH query to apply.
那么实际上就是去看Selector 相关的函数了。
————————————————
<p> AA <sub>1</sub> <sub>2</sub> <sub>3</sub> </p> <p> BB <sub>1</sub> <sub>2</sub> <sub>3</sub> </p>
对于上述例子,其实可以考虑获取到p之后,对其内容再进行一次查找,即可获得 1 、2 、3的内容。
另外提问的话把自己的环境、代码描述全一点会对自己更有帮助
试试abstract =sel.xpath('//p[@id ="abstractBox"]/node()').extract()
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
没猜错的话
用的Scrapy?
sel.xpath() 得到的依旧是一个SelectorList
参看原文档
那么实际上就是去看Selector 相关的函数了。
————————————————
对于上述例子,其实可以考虑获取到p之后,对其内容再进行一次查找,即可获得 1 、2 、3的内容。
另外
提问的话把自己的环境、代码描述全一点会对自己更有帮助
试试
abstract =sel.xpath('//p[@id ="abstractBox"]/node()').extract()