使用 JSoup 获取隐藏在 HTML 代码中的 URL
我有一段网页(库的东西)的 HTML 代码,例如:
<div class="qelcontent" id="4ed0e0ba4f1b16.47984984" style="display:block;">
<div class="description"><h4 class="first"><b>Amazon.com Product Description</b>
(<a href="https://rads.stackoverflow.com/amzn/click/com/0860783227" rel="nofollow noreferrer">ISBN 0860783227</a>, Hardcover)</h4>
我想从 href
属性获取绝对 URL。我尝试过:
selector = document.select(".first .a[href]");
但它返回了null
。我怎样才能得到这个值?
I have a piece of HTML code of a web page (library thing) like:
<div class="qelcontent" id="4ed0e0ba4f1b16.47984984" style="display:block;">
<div class="description"><h4 class="first"><b>Amazon.com Product Description</b>
(<a href="https://rads.stackoverflow.com/amzn/click/com/0860783227" rel="nofollow noreferrer">ISBN 0860783227</a>, Hardcover)</h4>
I want to get the absolute URL from an href
attribute. I tried:
selector = document.select(".first .a[href]");
But it returned null
. How can I get the value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这解决了这个特定问题..不确定它是否适用于您的整个数据集。
This solves this specific problem.. not sure if it will work with your entire dataset.