Android Basic JSOUP Tutorial

  • Aravind Asthme

    nice article

  • Pierre Lel Mustang

    Helped a lot . thanks

  • Shuai Wang


  • Zhubarb

    Thank you, this is very helpful. However, I noticed that it is quite slow. I guess due to having to fetch the entire document separately for all Async Tasks? Wouldn’t it be faster to run “Document document = Jsoup.connect(url).get();” once and then let the buttons access the different parts of the ‘document’?

  • André Felipe

    It’s a good article, but I have a problem. I do everything which is written in the article, but the app don’t work, I used the debug and I discovered where is the problem, apparently, the problem is when the Jsoup try to open a connection com a url(Jsoup.connect(url).get()), but I don’t know how to fix this?

    • Patrik

      Make sure you export jsoup (properties –> Java build path –> Order and export)

      • ethanchan

        i have the same problem too…there is an error in “doInBackground”

  • AndroidBegin

    Hi developers, this tutorial may not be working at the moment because of the changes I made to this website. I will update the current tutorial as soon as possible.

  • zurche

    This is an AWESOME tutorial. Thank you very much for sharing this.


    Hello, what if i want to create a xml layout with the same structure of a div from a website, maybe ‘ Hello ‘ …. how can i add each data into the corresponding field on my xml layout ‘ image.jpgtext ???


    My emulator is not showing the app, throws an error! i tried with an other website but same happens… what should i do?

  • Guest

    Great! thx

  • KK

    Awesome example

  • Midhun

    I’m getting the text but the image is not being downloaded . Can you suggest anything that might be causing this?

    • Midhun

      oh i got it……the img tag in the website doesn’t fall between h1 tags anymore… you have to change the jsoup selection.

      • AndroidBegin

        Hi Midhun, glad you solve your problems. I will update this tutorial soon to correct the coding.

  • golon


  • jura7

    I always get the same error in logcat. Can anybody help, please? When I click on title button progress dialog shows for few seconds and then my app crashes:/ Here below is my logcat if it helps.

  • AndroidBegin

    Hi Developers, I’ve made the changes accordingly. Should be working fine now. Thanks

  • Paulo Roberto

    How I do I capture the contents of a DIV?

    Already tried changing the code and Napo was … In place of the description of the site, want to capture all the contents of a div.

    This is the site structure:

    Agarradinhos às orelhas

    26 de janeiro de 2015


    tried to change this way, I need to do what he gets content


    protected Void doInBackground(Void… params) {

    try {

    // Connect to the web site

    Document document = Jsoup.connect(url).get();

    // Using Elements to get the Meta data

    Elements div = document


    // Locate the content attribute

    desc = div.attr(“p”);

    } catch (IOException e) {



    return null;


  • DomenicoButtafarro

    I have this html code:

    <a href="…

    I writed this, but this give me an error:

    Element image ="li[class*cat-item cat-item-1965]").first();

  • Steve

    Hi, is there any way to get the website logo? I tried your code above, but its different for every website. I tried with Facebook and it can’t get the logo.

    • Mr.Anonymous

      some website protect their web source.

  • AndroidBegin

    Hi Guys, we’ve just redesign the whole Website, the code and sample above will not work at the meantime. Please take note. Thanks.

  • Alexy Vercruysse

    Awesome work =)