XPath定位中and、or、not、contains、starts-with和string(.)用法

下文总结了XPath常用的text()、and、or、not、contains,当然也还有类似的position、last、ends_with、starts_with等等。

data1 = selector.xpath("//input[@type='submit' and @name='fuck']");
data2 = selector.xpath("//input[@type='submit' or @name='fuck']");
data2 = selector.xpath("//input[@type='submit' and not(contains(@name,'fuck'))]");
data3 = selector.xpath("//input[starts-with(@id,'fuck')]"));
data4 = selector.xpath("//input[ends-with(@id,'fuck')]"));
data5 = selector.xpath("//input[contains(@id,'fuck')]"));

posted @ 2022-01-21 17:53  brady-wang  阅读(531)  评论(0编辑  收藏  举报