Selenium WebDriver Java Framework Course Limited Time Offer for $50

Selenium WebDriver Java Framework Course Limited Time Offer for $50


Parse HTML From Web With Jsoup

jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods. This article explains how to parse html from web with Jsoup library. We obtain all links from the website "".  

Step 1: create a maven based java project and add the following dependency in the pom.xml file


Write the following code in the class "" file.

package com.example.html;

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


public class ParseHtmlFromUrl {

    public static void main(String[] args) {
        //Define a document
        Document doc = null;
        try {
            //fetch and parse html from the web
            doc = Jsoup.connect("").get();
            //get the title of the website
            String title = doc.title();
            //print out title
            //get all links
            Elements links=doc.getElementsByTag("a");
            //print link text from each link
            for(Element link: links)
        } catch (IOException e) {


Run the code above and see the result below. All links with the web page "" are displayed. 

Skip to main content

Mahara user manual

Mahara user manual
Mahara wiki
Mahara homepage

Terms and conditions
Privacy statement
Contact us