类 HTMLExtractor


  • public class HTMLExtractor
    extends Object
    HTML正文抽取器
    作者:
    frankcl
    • 构造器详细资料

      • HTMLExtractor

        public HTMLExtractor()
    • 方法详细资料

      • mainHTMLElement

        public static org.jsoup.nodes.Element mainHTMLElement​(String html,
                                                              String url)
        抽取HTML主体元素 针对新闻文章网页生效
        参数:
        html - 网页HTML
        url - 网页URL
        返回:
        存在返回正文主体元素,否则返回null
      • publishTime

        public static Long publishTime​(org.jsoup.nodes.Element mainElement)
        从正文主体中抽取发布时间 如果无法抽取返回null
        参数:
        mainElement - 主体元素
        返回:
        成功返回毫秒时间戳,否则返回null
      • formatHTML

        public static String formatHTML​(String html,
                                        String url)
        格式化HTML内容 以分段元素p构建HTML内容
        参数:
        html - HTML内容
        url - 网页URL
        返回:
      • formatHTMLElement

        public static String formatHTMLElement​(org.jsoup.nodes.Element htmlElement)
        格式化HTML内容 以分段元素p构建HTML内容
        参数:
        htmlElement - HTML元素
        返回:
        HTML内容