37,981
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
从这样的HTML文档中抓取电影名字
使用lmxl库时,匹配以下格式:
result = text.xpath('//div/a/@title')
结果是抓取不到数据
更改抓取格式,如下:
result = text.xpath('//div//a/@title')
就可以成功抓取
这是怎么一回事!!!!
a不是div的子节点吗?
为什么要用子孙节点才能抓取???
为什么要用子孙节点才能抓取???
首先你要定位到需要的a标签的父级标签,比如那个p标签(//p[@class="name"]/a/@title)