Social Icons

Tuesday, April 27, 2010

jsoup: Java HTML Parser


Suppose you want to retrieve all the links in HTML page . And you stored the HTML code in a String . Using regex is a cumbersome task. you need extensive testing against number of variations. jsoup is a class library developed to this very reason. Here is the code using jsoup to parse the HTML String and retrieve all the links.

_________________________________________________________

jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.

  • parse HTML from a URL, file, or string
  • find and extract data, using DOM traversal or CSS selectors
  • manipulate the HTML elements, attributes, and text
  • clean user-submitted content against a safe white-list

jsoup is designed to deal with all varieties of HTML found in the wild; from pristine and validating, to invalid tag-soup; jsoup will create a sensible parse tree.


 
 
Blogger Templates http://slots.to/