Package 

Class PrimerParser


  • 
    public final class PrimerParser
    
                        

    A very simple DOM parser

    A collection of methods for extracting content from DOM trees.

    This class holds a few utility methods for pulling content out of DOM nodes, such as getLiveLinks, getPageText, etc.

    • Constructor Detail

      • PrimerParser

        PrimerParser(ImmutableConfig conf)
    • Method Detail

      • getConf

         final ImmutableConfig getConf()
      • getPageText

         final Boolean getPageText(StringBuilder sb, Node root, Boolean abortOnNestedAnchors)

        This method takes a StringBuilder and a DOM Node, and will append all the content text found beneath the DOM node to the StringBuilder.

        If abortOnNestedAnchors is true, DOM traversal will be aborted and the StringBuffer will not contain any text encountered after a nested anchor is found.

      • collectLinks

         final Set<HyperlinkPersistable> collectLinks(URL base, Node root)

        This method finds all anchors below the supplied DOM root, and creates appropriate HyperlinkPersistable records for each (relative to the supplied base URL), and adds them to the outlinksArrayList.

        Links without inner structure (tags, text, etc) are discarded, as are links which contain only single nested links and empty text nodes (this is a common DOM-fixup artifact, at least with nekohtml).