user308808
user308808

Reputation:

Text extraction with java html parsers

I want to use an html parser that does the following in a nice, elegant way

  1. Extract text (this is most important)
  2. Extract links, meta keywords
  3. Reconstruct original doc (optional but nice feature to have)

From my investigation so far jericho seems to fit. Any other open source libraries you guys would recommend?

Upvotes: 0

Views: 3943

Answers (3)

Vin Chenzo
Vin Chenzo

Reputation: 81

I would definitely go for JSoup.

Very elegant library and does exactly what you need.

See Example Here

Upvotes: 2

Finbarr
Finbarr

Reputation: 32126

I recently experimented with HtmlCleaner and CyberNekoHtml. CyberNekoHtml is a DOM/SAX parser that produces predictable results. HtmlCleaner is a tad faster, but quite often fails to produce accurate results.

I would recommend CyberNekoHtml. CyberNekoHtml can do all of the things you mentioned. It is very easy to extract a list of all elements, and their attributes, for example. It would be possible to traverse the DOM tree building each element back into HTML if you wanted to reconstruct the page.

There's a list of open source java html parsers here: http://java-source.net/open-source/html-parsers

Upvotes: 2

William
William

Reputation: 15583

I ended up using HtmlCleaner http://htmlcleaner.sourceforge.net/ for something similar. It's really easy to use and was quick for what I needed.

Upvotes: 0

Related Questions