Wednesday, January 22, 2014

Parse HTML Table with Jsoup

Hi All,

Let me share with you the java code that helps me to extract data from html table. The code is based on the Jsoup library that you can add it to your project through Maven repository


or you add the Jsoup jar into the project build path (JAR available here : )

package org.tunindex.parser;


import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class MainClass {

 public static void main(String[] args) {
  Document doc = null;
  try {
   doc = Jsoup.connect("").get();
  } catch (IOException e) {

     for (Element table :"table")) {
         for (Element row :"tr")) {
             Elements tds ="td");
             if (tds.size() > 6) {
                 System.out.println(tds.get(0).text() + ":" + tds.get(1).text());


 Hope it helps you

Good night :-)

No comments:

Post a Comment