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

<dependency>
 <groupId>org.jsoup</groupId>
 <artifactId>jsoup</artifactId>
 <version>1.7.1</version>
  </dependency>





or you add the Jsoup jar into the project build path (JAR available here : http://jsoup.org/download )

package org.tunindex.parser;

import java.io.IOException;

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

public class MainClass {

 public static void main(String[] args) {
  Document doc = null;
  try {
   doc = Jsoup.connect("http://www.bvmt.com.tn/quotes/resume-data.jsp").get();
   
  } catch (IOException e) {
   
   e.printStackTrace();
  }

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

 }

} 
 Hope it helps you

Good night :-)

Monday, January 13, 2014

Server Tomcat v7.0 Server at localhost failed to start



Hi All,

Hope you are doing good.

A weak error, I faced today with eclipse when I was trying to deploy a java web application on Tomcat, occurred during Tomcat Startup. Following the error message shown in Eclipse:
Server Tomcat v7.0 Server at localhost failed to start

To resolve this problem, follow the instructions:

  1. Delete tmp0 folder inside
    <workspace-directory>\.metadata\.plugins\org.eclipse.core.resources
  2. Do the Eclipse Magic Steps: Clean the workspace and restart Eclipse
Let me know if you have more efficient solution

Good Bye :-)