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')]"));