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;
}
爬虫抽取网页中同层级多标签元素
最新推荐文章于 2023-01-03 20:34:37 发布