当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
25 Star 86 Fork 22

scrapy4j / htmlp
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

htmlp

概述

Html 页面内容中属性的自动解析工具,自动提取文章标题、正文、作者、发布时间、来源、原始来源

使用

// 提取正文
String txt = HtmLP.getContent(html).getTxt(); // 正文不带标签
String content = HtmLP.getContent(html).getContent(); // 正文带标签
// 提取标题
String title = HtmLP.getTitle(html, metaTitle);
// 提取作者
String author = HtmLP.getAuthor(txt);
// 提取时间
String time = HtmLP.getTime(html);

原理

正文提取

基于行块统计的正文提取,认为:当页面中内容过滤掉 html 标签后,剩余的内容逐行统计字数,指定行数后的数量当大于阈值时,则认为是正文的开始,当再次小于指定阈值时,认为正文已结束

标题提取

取正文中与 title 标签内容最相似的内容为标题

属性提取(作者、时间、来源)

基于正则的数据提取,同时来源认为有两种,一种是设定当前网站为文章来源,一种是当前网站会转发来自其它媒体的文章,此时其它媒体则做为一种来源,根据实际需求自行选择提取方法

The MIT License (MIT) Copyright (c) 2018 Yunlong Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Html 页面内容中属性的自动解析工具,自动提取文章标题、正文、作者、发布时间、来源、原始来源 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/scrapy4j/htmlp.git
git@gitee.com:scrapy4j/htmlp.git
scrapy4j
htmlp
htmlp
master

搜索帮助