Android:从HTML代码获取链接(没有标签/ID)

Android: get link from HTML-code (no tag/id)

本文关键字:标签 ID 链接 HTML 代码 获取 Android      更新时间:2023-09-26

我想download an iCal file to my app.它工作正常,但指向此文件的链接将change every 6 months.继承文件链接的页面/链接不会更改,因此我想查看main page and find the link to the iCal file to download it.的代码

我认为这可能最适合javascript,但我对此一无所知。也没有我可以搜索的标签或 ID。

这是搜索链接的页面:

https://stundenplan.hs-furtwangen.de/splan/std?act=tt&lan=de&pu=-1&sel=pg&og=1433&pg=CNB4

搜索模式将"/splan/ical" 在那里我找到了该文件的链接。

最后,我需要"/splan/ical?type=pg&puid=6&pgid=1617&lan=de"存储在某个地方。

现在我只是使用Downloadmanager来获取文件,没有html代码存储在任何地方。

希望有人能帮忙。谢谢。

编辑:

以下是包含链接的 html 源代码的一部分(第一个 href):

<tr>
	<td />
	<td colspan="1"><a
		href="/splan/ical?type=pg&amp;puid=8&amp;pgid=2505&amp;lan=de"><img
			style="align: middle; border: 0;" src="/splan/pictures/ical.png"
			alt="ics feed" height="20" /></a> 
<a href="http://www.progotec.de/site/splandok/iCal-Anbindung"
	target="_blank"><img style="align: middle; border: 0;"
	alt="Hilfe zu ICal"
	src="/splan/pictures/hilfe.png"
	title="Hilfe zu ICal" height="20" /></a>
</td>
</tr>

我不确定你要找什么,但是有了这个javscript脚本,你可以找到链接。

//like this you could look for the link on the page
//search done with Regularexpression
alert(document.body.innerHTML.match(/('/splan'/ical[^"]*)/gi));
<body>
<!-- THIS WOULD HAVE TO BE THE BODY OF THE PAGE -->
  ...
  <a
		href="/splan/ical?type=pg&amp;puid=8&amp;pgid=2505&amp;lan=de"><img
			style="align: middle; border: 0;" src="/splan/pictures/ical.png"
			alt="ics feed" height="20" /></a> 
  ...
</body>

这是整个 stundenplan.hs-furtwangen.de 的正则表达式演示:http://regex101.com/r/wF3wU4/1

相关文章: