Class XpathSelector

java.lang.Object
us.codecraft.webmagic.selector.BaseElementSelector
us.codecraft.webmagic.selector.XpathSelector
All Implemented Interfaces:
ElementSelector, Selector

public class XpathSelector extends BaseElementSelector
XPath selector based on Xsoup.
Since:
0.3.0
Author:
code4crafter@gmail.com
  • Constructor Details

    • XpathSelector

      public XpathSelector(String xpathStr)
  • Method Details

    • select

      public String select(org.jsoup.nodes.Element element)
      Description copied from interface: ElementSelector
      Extract single result in text.
      If there are more than one result, only the first will be chosen.
      Parameters:
      element - element
      Returns:
      result
    • selectList

      public List<String> selectList(org.jsoup.nodes.Element element)
      Description copied from interface: ElementSelector
      Extract all results in text.
      Parameters:
      element - element
      Returns:
      results
    • selectElement

      public org.jsoup.nodes.Element selectElement(org.jsoup.nodes.Element element)
      Specified by:
      selectElement in class BaseElementSelector
    • selectElements

      public List<org.jsoup.nodes.Element> selectElements(org.jsoup.nodes.Element element)
      Specified by:
      selectElements in class BaseElementSelector
    • hasAttribute

      public boolean hasAttribute()
      Specified by:
      hasAttribute in class BaseElementSelector