类 HTMLExtractor


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

      • HTMLExtractor

        public HTMLExtractor()
    • 方法详细资料

      • extractMainElement

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

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

        public static String buildMainHTML​(org.jsoup.nodes.Element mainElement)
        构建HTML内容 以分段元素p构建HTML内容
        参数:
        mainElement - 主体元素
        返回:
        HTML内容