简体   繁体   中英

read td class from url using java

hello i need little help reading website content

i want to read

    <tr>
<td class="text-center"><strong>This Month</strong></td>
<td class="text-center">1194</td>
<td class="text-center">22</td>
<td class="text-center">7</td>
</tr>

i make it like this but it always return nothing

if (url.toLowerCase().contains("top100arena.com") && line.contains("<strong>This Month</strong></td><td class=\"text-center\">"))
                        return Integer.valueOf(line.split(">")[1].replace("</td", "").replace(",", ""));

if you are considering using third-party libraries, jsoup is a good idea.

https://jsoup.org/

using css / xpath selectors, you can indicate the element you are interested in, eg

//tr/td[contains (strong,.)]

will find all bold entries, then we can get the parent for that element, and read all the elements

http://xpather.com/

https://devhints.io/xpath

jsoup: How to select the parent nodes, which have children satisfying a condition

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