gpt4 book ai didi

java - 从本地 HTML 页面抓取 Android 应用程序的数据

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

我正在尝试为 Android 的时间表应用程序收集数据信息。 html 看起来像这样:

      <td   bgcolor='#C0C0C0' colspan='1'><font color='#FFFFFF'>9:00</font></td>     
<td bgcolor='#C0C0C0' colspan='1'><font color='#FFFFFF'>9:15</font></td>
<td bgcolor='#C0C0C0' colspan='1'><font color='#FFFFFF'>9:30</font></td>

还有这样的:

     <td align='left'><font color='#FF0000'>Mobility</font></td>
</tr>
</table>
<table cellspacing='0' border='0' width='100%'>
<col align='left' />
<col align='right' />
<tr>
<td align='left'><font color='#000000'>P2016</font></td>
<td align='right'><font color='#008000'>E.Palin</font></td>
</tr>
</table>
<table cellspacing='0' border='0' width='100%'>
<col align='left' />
<tr>
<td align='left'><font color='#000080'>22-29, 32-36</font></td>
</tr>
</table>

我在 android studio 中使用 java 和 jsoup,我想知道如何在代码方面明智地抓取它,以便我可以获得不同的时间和“Mobility”、“P2016”、“E.Palin”和“22” -29、32-36"出现在我的申请中?

最佳答案

首先,您的 HTML 格式不正确或者它只是一个示例?

Estivate你可以这样写 JSoup 查询:

    File input = new File("C:\\path\\to\\html.html");

Document document= Jsoup.parse(input , "UTF-8", "/");

EstivateMapper mapper = new EstivateMapper();
Result result = mapper.map(document, Result.class);

结果类为:

    public class Result {

@Text(select = "font:matchesOwn(.*:.*)")
public List<String> times;

@Text(select = "font:not(:matchesOwn(.*:.*))")
public List<String> others;

}

您将获得 2 个列表:times=[9:00, 9:15, 9:30], others=[Mobility, P2016, E.Palin, 22-29, 32-36]

关于java - 从本地 HTML 页面抓取 Android 应用程序的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36333383/

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