public static String getDesc(Document doc) {
        String desc = "";
        Elements element_contents_all = doc.select("h1,h2,blockquote,p");
        for (Element element : element_contents_all) {
            desc += element.text() + " ";
            if (desc.length() >= 400) {
                logger.info("\t内容超过400字,停止抽取。");
                logger.info(desc);
                break;
            }
        }
        return desc;
    }

asoren
404 声望15 粉丝

引用和评论

0 条评论