xpath的用法

//div[@class="bar-bottom-wrap"]   匹配 class 属性为 "bar-bottom-wrap" 的div标签
也可以不指定标签类型

//*[@class="bar-bottom-wrap"]
上述xpath 匹配任意类型的标签,且标签的 class 属性为 bar-bottom-wrap

//*[@class]
上述表达式匹配所有具备class 属性的任意标签

//div[@id="app" and @class="m-container-max"]
用 and 可以拼接多个属性

在xpath中,一个点表示自己,两个点表示父元素

//span[text()="要闻榜"]
上述表达式根据标签对中间的文本值定位

可以不指定标签类型
//*[text()="要闻榜"]

也可以匹配所有有文本的
//span[text()]

//span[contains(text(), "要闻")]
上述表达式可以模糊匹配文本

 

 

 

posted @ 2020-12-17 11:03  西西cc  阅读(105)  评论(0编辑  收藏  举报