forked from karussell/snacktory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
57 lines (41 loc) · 2.08 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
= Snacktory
This is a small helper utility for pepole 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 and extract its text and its important picture.
Have a look into http://jetsli.de where Snacktory is used. Jetslide is a new way to consume news,
it does not only display the Websites' title but it displays a small preview of the site ('a snack')
and the important image if available.
= License
The software stands under Apache 2 License and comes with NO WARRANTY
= Features
Snacktory borrows some ideas from jReadability
https://github.com/ifesdjeen/jReadability
and goose (ideas + a lot test cases):
https://github.com/jiminoc/goose
The advantages over jReadability are
* better article text detection than jReadability
* only Java deps
* more tests
The advantages over Goose are
* similar article text detection although better detection for none-english sites (German, Japanese, ...)
* snacktory does not depend on the word count in its text detection to support CJK languages
* no external Services required to run the core tests => faster tests
* better charset detection
* with url resolving, but caching is still possible after resolving
* skipping some known filetypes
The disadvantages to Goose are
* only top image and top text supported at the moment
* some articles which passed do not pass.
But added a bunch of other useful sites (stackoverflow, facebook, other languages ...)
= Build
via Maven. Maven will automatically resolve dependencies to jsoup, log4j and slf4j-api
= Usage
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(url, resolveTimeout, true);
String text = res.getText();
String title = res.getTitle();
String imageUrl = res.getImageUrl();