简体   繁体   中英

java JSOUP select attribute

I want to add all attributes of div in html page.

<div data-brackets-id="6217" class="layout-internal col-12 js-autosuggest__search-list-container"> 

        Document doc = Jsoup.connect(url + text).get();
    Elements info = doc.select("div[data-brackets-id]");
    System.out.println(info);

but it does not works...

You can get the attribute like this:

Elements info = doc.select("div[data-brackets-id]");

// iterate the Elements
for(Element elm: info){
    System.out.println(elm.attr("data-brackets-id"));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM