• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

karussell/snacktory: Readability clone in Java

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

karussell/snacktory

开源软件地址:

https://github.com/karussell/snacktory

开源编程语言:

HTML 98.3%

开源软件介绍:

Future

Snacktory is no longer actively maintained by @karussell.

Crux is a fork under active development and is the recommended alternative.

  • Available under the same permissive Apache 2.0 License.
  • Adds several new features, such as Rich Text output (HTML), preserves links, extracts more metadata content, etc.
  • Optimized for Android. Decoupled from optional dependencies such as HttpUrlConnection, log4j, etc.
  • Actively developed by Chimbori, the developers of Hermit, a Lite Apps Browser for Android.
  • Already being used in multiple apps.
  • Crux has a different architecture from Snacktory: it is designed as a collection of several separate APIs instead of a single one. Clients can pick and choose which ones they wish to use.
  • As a result, Crux is not a drop-in replacement for Snacktory, but fairly easy to migrate to.

Snacktory

This is a small helper utility for people who don't want to write yet another java clone of Readability. In most cases, this is applied to articles, although it should work for any website to find its major area, extract its text, keywords, its main picture and more.

The resulting quality is high, even paper.li uses the core of snacktory. Also have a look into this article, it describes a news aggregator service which uses snacktory. But jetslide is no longer online.

Snacktory borrows some ideas and a lot of test cases from goose and jreadability:

License

The software stands under Apache 2 License and comes with NO WARRANTY

Features

  • article text detection
  • get top image url(s)
  • get top video url
  • extraction of description, keywords, ...
  • good detection for none-english sites (German, Japanese, ...), snacktory does not depend on the word count in its text detection to support CJK languages
  • good charset detection
  • possible to do URL resolving, but caching is still possible after resolving
  • skipping some known filetypes
  • no http GET required to run the core tests

TODOs

  • only top text supported at the moment

Usage

Include the repo at: https://github.com/karussell/mvnrepo

Then add the dependency

<dependency>
   <groupId>de.jetwick</groupId>
   <artifactId>snacktory</artifactId>
   <version>1.1</version>
   <!-- or if you prefer the latest build <version>1.2-SNAPSHOT</version> -->
</dependency>

If you need this for Android be sure you read this issue.

Or, if you prefer, you can use a build generated by jitpack.io.

Now you can use it as follows:

HtmlFetcher fetcher = new HtmlFetcher();
// set cache. e.g. take the map implementation from google collections:
// fetcher.setCache(new MapMaker().concurrencyLevel(20).maximumSize(count).
//    expireAfterWrite(minutes, TimeUnit.MINUTES).makeMap();

JResult res = fetcher.fetchAndExtract(articleUrl, resolveTimeout, true);
String text = res.getText(); 
String title = res.getTitle(); 
String imageUrl = res.getImageUrl();

Build

via Maven. Maven will automatically resolve dependencies to jsoup, log4j and slf4j-api




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
alibaba/Alibaba-Java-Coding-Guidelines: Gitbook for AJCG发布时间:2022-06-23
下一篇:
aerospike/aerospike-client-java: Aerospike Java Client Library发布时间:2022-06-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap