简体   繁体   English

使用 java 从 url 读取 td class

[英]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.如果您正在考虑使用第三方库,jsoup 是一个好主意。

https://jsoup.org/ https://jsoup.org/

using css / xpath selectors, you can indicate the element you are interested in, eg使用 ZC7A62​​8CBA22E28EB17B5F5C6AE2A266AZ / xpath 选择器,您可以指出您感兴趣的元素,例如

//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/ http://xpather.com/

https://devhints.io/xpath https://devhints.io/xpath

jsoup: How to select the parent nodes, which have children satisfying a condition jsoup:如何 select 有满足条件的子节点的父节点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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