【笔记整理】xpath复习

又是xpath.... 10年前学java就学过了...哈哈哈

要就看w3cschool的教程就行了,

函数部分会用得到:

https://www.w3school.com.cn/xpath/xpath_functions.asp

举个例子:

element.xpath("//div[contains(@class, 'title')]")
//*[contains(@class,'filter') and contains(@class,'clearfix')]/a/text() 获取 class属性值包含 filte并且包含 clearfix的任意元素下的 a 子节点中的文本
//a[not(contains(@href,'detail'))] 选取任何a标签中href属性不包含detail的a标签
//a[text()=‘baidu’] 选取a标签的text等于baidu的a标签
//a[starts-with(@href,'//detail.tmall.com')] a标签属性href开头等于//detai.tmall.com
posted @ 2023-07-17 11:07  蕝戀  阅读(4)  评论(0编辑  收藏  举报