gpt4 book ai didi

Android:如何解析 HTML 站点并只获取一些特定数据?

转载 作者:行者123 更新时间:2023-11-30 04:30:12 24 4
gpt4 key购买 nike

我有一个问题:

我有一个链接:http://wap.nastabuss.se/its4wap/QueryForm.aspx?hpl=Teleborg+C+(V%C3%A4xj%C3%B6 )我只想从此链接中获取一些特定数据并显示在 Android 的 TextView 中。

这在 Android 中是否可行,我的意思是是否有机会通过解析或者我不知道,你们可以建议我。

例如,我只想从该站点获取此列 Nästa tur (min)。

问候

最佳答案

JSoup非常好并且越来越受欢迎。以下是您如何解析整个表格:

URL url = new URL("http://www.nseindia.com/content/equities/niftysparks.htm");
Document doc = Jsoup.parse(url, 3000);

Element table = doc.select("table[title=Avgångar:]").first();

Iterator<Element> it = table.select("td").iterator();

//we know the third td element is where we wanna start so we call .next twice
it.next();
it.next();
while(it.hasNext()){
// do what ever you want with the td element here

//iterate three times to get to the next td you want. checking after the first
// one to make sure
// we're not at the end of the table.
it.next();
if(!it.hasNext()){
break;
}
it.next();
it.next();
}

关于Android:如何解析 HTML 站点并只获取一些特定数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7863082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com