【发布时间】:2020-12-18 10:43:30
【问题描述】:
我有一个包含网站的 web 视图。 我想从页面中提取一个 int 值。 我要转换的部分的html代码是:
<body>
<div class="toolbar" id="main-toolbar">
<a> <!-- something--> </a>
<a> <!-- something--> </a>
<a> <!-- something--> </a>
<a href="https://thesitethatI'mtalkingabout.com/it/me/notifications" data-unread="1" class="toolbar__item cta-login ">
<span class="is-icon-bell toolbar__icon"></span>
<span class="toolbar__badge">1</span>
"
Notifications
"
</a>
<!--this is the notification number, if you aren't logged in this would be empty-->
</div>
</body>
现在我将从页面中提取值(在本例中为 1)并用它在我的应用程序中创建一个变量。我怎样才能做到这一点? 能够从 data-unread"1" 而不是从 span 中提取值会更好。
我要查找的数字是网站的通知计数。为了让Jsoup找到他,他必须登录。我使用的webView允许你登录。Jsoup有没有办法分析页面的HTML,因为它出现在webview中?
【问题讨论】:
标签: android html android-studio webview jsoup