Annotation Type ExtractBy


  • @Retention(RUNTIME)
    @Target({FIELD,TYPE})
    public @interface ExtractBy
    Define the extractor for field or class.
    Since:
    0.2.0
    Author:
    code4crafter@gmail.com
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String value
      Extractor expression, support XPath, CSS Selector and regex.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean multi
      Deprecated.
      since 0.4.2
      boolean notNull
      Define whether the field can be null.
      If set to 'true' and the extractor get no result, the entire class will be discarded.
      ExtractBy.Source source
      The source for extracting.
      ExtractBy.Type type
      Extractor type, support XPath, CSS Selector and regex.
    • Element Detail

      • value

        java.lang.String value
        Extractor expression, support XPath, CSS Selector and regex.
        Returns:
        extractor expression
      • type

        ExtractBy.Type type
        Extractor type, support XPath, CSS Selector and regex.
        Returns:
        extractor type
        Default:
        us.codecraft.webmagic.model.annotation.ExtractBy.Type.XPath
      • notNull

        boolean notNull
        Define whether the field can be null.
        If set to 'true' and the extractor get no result, the entire class will be discarded.
        Returns:
        whether the field can be null
        Default:
        false
      • source

        ExtractBy.Source source
        The source for extracting.
        It works only if you already added 'ExtractBy' to Class.
        Returns:
        the source for extracting
        Default:
        us.codecraft.webmagic.model.annotation.ExtractBy.Source.SelectedHtml
      • multi

        boolean multi
        Deprecated.
        since 0.4.2
        Define whether the extractor return more than one result. When set to 'true', the extractor return a list of string (so you should define the field as List).
        Deprecated since 0.4.2. This option is determined automatically by the class of field.
        Returns:
        whether the extractor return more than one result
        Default:
        false