Class JSoupParser

java.lang.Object
org.apache.tika.parser.AbstractEncodingDetectorParser
org.apache.tika.parser.html.JSoupParser
All Implemented Interfaces:
Serializable, org.apache.tika.parser.Parser

public class JSoupParser extends org.apache.tika.parser.AbstractEncodingDetectorParser
HTML parser. Uses JSoup to turn the input document to HTML SAX events, and post-processes the events to produce XHTML and metadata expected by Tika clients.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Charset
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    JSoupParser(org.apache.tika.detect.EncodingDetector encodingDetector)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.tika.detect.EncodingDetector
    getEncodingDetector(org.apache.tika.parser.ParseContext parseContext)
    Look for an EncodingDetetor in the ParseContext.
    Set<org.apache.tika.mime.MediaType>
    getSupportedTypes(org.apache.tika.parser.ParseContext context)
     
    boolean
     
    void
    parse(InputStream stream, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context)
     
    void
    parseString(String html, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context)
     
    void
    setExtractScripts(boolean extractScripts)
    Whether or not to extract contents in script entities.

    Methods inherited from class org.apache.tika.parser.AbstractEncodingDetectorParser

    getEncodingDetector, setEncodingDetector

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_CHARSET

      public static final Charset DEFAULT_CHARSET
  • Constructor Details

    • JSoupParser

      public JSoupParser()
    • JSoupParser

      public JSoupParser(org.apache.tika.detect.EncodingDetector encodingDetector)
  • Method Details

    • getSupportedTypes

      public Set<org.apache.tika.mime.MediaType> getSupportedTypes(org.apache.tika.parser.ParseContext context)
    • isExtractScripts

      public boolean isExtractScripts()
    • setExtractScripts

      @Field public void setExtractScripts(boolean extractScripts)
      Whether or not to extract contents in script entities. Default is false
      Parameters:
      extractScripts -
    • parse

      public void parse(InputStream stream, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context) throws IOException, SAXException, org.apache.tika.exception.TikaException
      Throws:
      IOException
      SAXException
      org.apache.tika.exception.TikaException
    • parseString

      public void parseString(String html, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context) throws SAXException
      Throws:
      SAXException
    • getEncodingDetector

      protected org.apache.tika.detect.EncodingDetector getEncodingDetector(org.apache.tika.parser.ParseContext parseContext)
      Look for an EncodingDetetor in the ParseContext. If it hasn't been passed in, use the original EncodingDetector from initialization.
      Overrides:
      getEncodingDetector in class org.apache.tika.parser.AbstractEncodingDetectorParser
      Parameters:
      parseContext -
      Returns: