简单的xpath定位方式

xpath定位方法简介

//相对定位,1、全部元素
xpath=‘//*‘
//2、指定属性内容
xpath="//*[@text=‘任务中心‘]"
//3、包含属性内容,查找class属性中包含image的APP控件
xpath="//*[contains(@class,‘image‘)]"
//4、多条件同时满足筛选控件
xpath="//*[contains(@class,‘image‘) and contains(@enable,‘ture‘) ]"
//5、多条件,其中一条满足筛选控件
xpath="//*[contains(@class,‘image‘) or contains(@enable,‘ture‘) ]"
//6、ancestor,父类条件筛选
//查找class属性中包含image的APP控件且父辈为可见的
xpath="//*[contains(@class,‘image‘)]/ancestor::*// [contains(@enable,‘ture‘) ]"
//7、运算:选取价格高于 35 的所有 price 节点
xpath="/bookstore/book[price>35]/price"

简单的xpath定位方式

上一篇:400报错问题


下一篇:requests模块之post请求