How to parse a website in java using jsoup ?

How to parse a website in java using jsoup ?

What is Jsoup ?

Jsoup is a java library, used to parse and extract content of a website.

As well as it can do many things, few things are given below,

Parsing any website content using get or post method,
Can able to parse any HTML elements,
Attributes and text etc…..

Download link:

Parsing website ( using jsoup: is a rank provider website, that is they will give the rank for all the websites in the world based on the website traffic (global and regional wise).

Now we are going pass the website name and will get the rank details of the passed website using jsoup.

package in.javadomain;


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

public class AlexaRank {
	public static void main(String[] args) throws IOException {
		String site = "";
		String siteRank = getAlexaRank("");
		System.out.println("Alexa Rank of " + site + ": \n" + siteRank);

	public static String getAlexaRank(String siteName) throws IOException {
		String baseUrl = "" + siteName + "";
		String alexaRank = null;
		Document doc = Jsoup.connect(baseUrl).timeout(0).get();
		String globalRank ="span.globleRank")
		String countryRank ="span.countryRank")
		alexaRank = "Global Rank: " + globalRank + "\nCountry Rank: "
				+ countryRank;
		return alexaRank;



Alexa Rank of
Global Rank: 754,755
Country Rank: 235,150

Thanks for reading this post………..!!!

1,336 total views, 2 views today

One thought on “How to parse a website in java using jsoup ?

  1. I loved aѕ much as уou’ll receive carried out right hегe.

    Тhе sketch іs attractive, your authored subject matter stylish.
    nοnetheless, yоu command get gоt an edginess over thаt
    you wish be delivering the follοwing. unwell unquestionably сome further fοrmerly again sіnce eхactly the
    same nearly veгy often inside case you shield thіs increase.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.