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:

[java]
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.ngdeveloper.com").post();
doc = Jsoup.connect("http://www.ngdeveloper.com").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());
}
}
}

[/java]

Output:
[plain gutter=”false”]Javadomain website Title => Javadomain[/plain]

Leave a Reply