gpt4 book ai didi

java - 如何使用java从html页面获取数据?

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

如何从XML/HTML页面获取数据?

我想制作一个 Android 应用程序,用户可以在其中收到学校类(class)失败的通知。网站是这样的: http://www.anony.ws/image/pC9

用户在安装应用程序后填写他们的学校类(class) (klas)。我想从表中选择数据,如果是他们的类(class),用户应该收到通知。 (例如:

if ( userClass == klas ), then alert ("hey, " + was + " will be " + was + "because of" + opmerking); 

类似的东西。但我不知道应该如何从表中挑选数据,这是一个奇怪的页面。使它变得更加困难,因为页面从 (1/2) 淡出到 (2/2)(每页最多 10 个列表,因此 50 个列表 = 5 页),在此处查找示例:http://suse.ghlyceum.nl/dagrooster/lwoo/ 。我应该如何选择数据并将它们放入 java 变量中!

我需要挑选的代码示例

<tr class='list odd'>
<td class="list" align="center">6V</td>
<td class="list" align="center">5</td>
<td class="list" align="center">fatl1</td>
<td class="list" align="center">fatl1</td>
<td class="list" align="center">MPs</td>
<td class="list" align="center">MPs</td>
<td class="list" align="center">D03</td>
<td class="list" align="center">lokaal wissel</td>

完整网站代码:

<html>
<head>
<title>Roosterwijzigingen Locatie Rijnwoude</title>
<meta http-equiv="expires" content="0">
<style type="text/css">
<!--

/* page title */
div.mon_title
{
font-weight: bold;
font-size: larger;
}

table.info
{
background-color: #FFB515;
border: 2px;
border-style:solid;
}

table.mon_list
{
background-color: #FFB515;
border: 2px;
border-style:solid;
}

td.info
{
font-size: 15px;
font-style: normal;
font-weight: 100;
}

th.list,
td.list
{
background-color: #FFB515;
font-size: 19pt;
font-style: normal;
font-weight: 100;
border: 2px;
border-style:solid;
}

-->
</style>
<meta name="generator" content="Untis 2013">
<meta name="company" content="Gruber &amp; Petters Software, A-2000 Stockerau, Austria, www.grupet.at">
</head>

<body bgcolor="#FEE9B1">
<CENTER>
<TABLE align="bottom" cellspacing="3" cellpadding="2">
<TR>
<TD align="bottom">
<font face="Verdana" size="6" color="#911083">Roosterwijzigingen</font>
<br><font size="4" color="#000000" face="Arial">Vestiging Rijnwoude</font>
</TD>

<TD>&nbsp;</TD>

<TD>

<TABLE width="100%" cellspacing="2" cellpadding="2">
<tr>
<TD></TD>
<TD>   </TD>
<TD></TD>
<TD>   </TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD>   </TD>
<TD></TD>
<TD>   </TD>
<TD><font size="-2">Gewijzigd 16-5-2013 13:54</size></TD>
</TR>
</TABLE>

</TD>

</tr>
</TABLE>
<p>

<font size="4" face="Arial">
<div class="mon_title">18-05-2013 Maandag</div>
<table class="mon_list" >
<tr class='list'>
<th class="list" align="center">Klas</th>
<th class="list" align="center">uur</th>
<th class="list" align="center">was</th>
<th class="list" align="center">wordt</th>
<th class="list" align="center">was</th>
<th class="list" align="center">wordt</th>
<th class="list" align="center">Vaklokaal</th>
<th class="list" align="center">opmerking</th>
</tr>



<tr class='list odd'>
<td class="list" align="center" style="background-color: #6f95d5">4H</td>
<td class="list" align="center" style="background-color: #6f95d5">5-6</td>
<td class="list" align="center" style="background-color: #6f95d5">nat1</td>
<td class="list" align="center" style="background-color: #6f95d5">---</td>
<td class="list" align="center" style="background-color: #6f95d5">MEn</td>
<td class="list" align="center" style="background-color: #6f95d5">---</td>
<td class="list" align="center" style="background-color: #6f95d5">---</td>
<td class="list" align="center" style="background-color: #6f95d5">aulauur</td>
</tr>

<tr class='list even'>
<td class="list" align="center">4V</td>
<td class="list" align="center">1</td>
<td class="list" align="center">econ3</td>
<td class="list" align="center">econ3</td>
<td class="list" align="center">SVn</td></td>
<td class="list" align="center">SVn</td>
<td class="list" align="center">310</td>
<td class="list" align="center">lokaal wissel</td>

</tr>

<tr class='list odd'>
<td class="list" align="center">6V</td>
<td class="list" align="center">5</td>
<td class="list" align="center">fatl1</td>
<td class="list" align="center">fatl1</td>
<td class="list" align="center">MPs</td>
<td class="list" align="center">MPs</td>
<td class="list" align="center">D03</td>
<td class="list" align="center">lokaal wissel</td>

</tr>

<tr class='list even'>
<td class="list" align="center" style="background-color: #6f95d5">6V</td>
<td class="list" align="center" style="background-color: #6f95d5">8</td>
<td class="list" align="center" style="background-color: #6f95d5">gs</td>
<td class="list" align="center" style="background-color: #6f95d5">---</td>
<td class="list" align="center" style="background-color: #6f95d5">NBa</td>
<td class="list" align="center" style="background-color: #6f95d5">---</td>
<td class="list" align="center" style="background-color: #6f95d5">---</td>
<td class="list" align="center" style="background-color: #6f95d5">aulauur</td>
</tr>

<tr class='list odd'>
<td class="list" align="center">6V</td>
<td class="list" align="center">7</td>
<td class="list" align="center">nat7</td>
<td class="list" align="center">nat7</td>
<td class="list" align="center">MEn</td>
<td class="list" align="center">JHo</td>
<td class="list" align="center">001</td>
<td class="list" align="center">het 6e of 8e uur</td>
</tr>


</table>
<p>
<font size="3" face="Arial">
Groene Hart Rijnwoude
</font></font>

</CENTER>
<p><center><font face="Arial" size="2"><a href="http://www.grupet.at" target="_blank" >Untis roostersoftware</a></font></center>
</body>
</html>

最佳答案

仅对格式正确的 HTML 文档使用 XML 解析器。为了解析 HTML 文档,例如您发布的文档(格式似乎不正确),请使用 JSoup被推荐。阅读食谱介绍,几分钟后您就可以开始了。

关于java - 如何使用java从html页面获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16665794/

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