Get element by class in JSoup

develoops picture develoops · Feb 17, 2012 · Viewed 37.4k times · Source

I try to get all info contained in div class named : bg_block_info, but instead i get info for another div class <div class="bg_block_info pad_20"> Why i'm getting it wrong ?

Document doc = Jsoup.connect("http://www.maib.md").get(); 
Elements myin = doc.getElementsByClass("bg_block_info");

Answer

Hauke Ingmar Schmidt picture Hauke Ingmar Schmidt · Feb 17, 2012

You can combine and chain selectors to refine your query, e.g.:

Document doc = Jsoup.connect("http://www.maib.md/").get();
Elements els = doc.getElementsByClass("bg_block_info").not(".pad_10").not(".pad_20");