逻辑操作

Xpath中的逻辑操作,主要有:

  • or:逻辑
  • and:逻辑
  • not:逻辑

or 逻辑或

举例:

可以同时搜到 class是b_algoclass值以b_ad开头的 li元素

allLiXpath = "//li[@class='b_algo' or starts-with(@class, 'b_ad')]"
resultLiList = resultElem.find_elements_by_xpath(allLiXpath)

not 逻辑非

举例:

  • //input[@name="identity" and not (contains(@class,'A'))]
  • //input[not(@class)]

results matching ""

    No results matching ""