user1163234
user1163234

Reputation: 2497

parsing Jsoup not working

I am trying to parse the hot topics from google trends in this link

I tried doing this but the elements size are always 0..

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

            if (doc != null) {

                Elements elements = doc..select("li");
                for (int i = 0; i < elements.size(); i++) {
                    String strValue  = elements.get(i).select("a").text();
                }

            }

Upvotes: 0

Views: 1309

Answers (1)

user2640782
user2640782

Reputation: 1084

I think the problem is, you cannot parce the content properly. You can use this:

    if (doc != null) {
         Elements elements = doc.select("content");
         for (int i = 0; i < elements.size(); i++) {
             Element element  = elements.get(i);
             Document doc2 = Jsoup.parse(element.text());
             Elements liElements =  doc2.select("li");
             for (Element liElemet : liElements) {
                 String strValue  = liElemet.select("a").text();
             }   
         }
     }

Upvotes: 1

Related Questions