Jul 23

Parsing Title of the Website using Jsoup

Howdy, You know you can parse any part of the website using the powerful open source tool called “Jsoup”.

Jsoup download link:

Jsoup Download Link

Example Program:

package in.javadomain;

import java.io.IOException;

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

public class TitleParseJsoup {

	/**
	 * Main Method to parse title of the website using jsoup
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Document doc;
		try {
			// You can use post method if needed like below.
			// Jsoup.connect("http://www.javadomain.in").post();
			doc = Jsoup.connect("http://www.javadomain.in").get();
			// title method gives the title of the website.
			String title = doc.title();
			System.out.println("Javadomain website Title => " + title);
		} catch (IOException e) {
			System.out.println("Exception in Jsoup  " + e.getMessage());
		}
	}
}

Output:

Javadomain website Title => Javadomain