国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
9. Working with URLs

Working with URLs

Problem

You have a HTML document that contains relative URLs, which you need to resolve to absolute URLs.

Solution

  1. Make sure you specify a base URI when parsing the document (which is implicit when loading from a URL), and
  2. Use the abs: attribute prefix to resolve an absolute URL from an attribute:
Document doc = Jsoup.connect("http://jsoup.org").get(); 
Element link = doc.select("a").first(); 
String relHref = link.attr("href"); // == "/" 
String absHref = link.attr("abs:href"); // "http://jsoup.org/"

Description

In HTML elements, URLs are often written relative to the document's location: <a href="/download">...</a>. When you use the Node.attr(String key) method to get a href attribute, it will be returned as it is specified in the source HTML.

If you want to get an absolute URL, there is a attribute key prefix abs: that will cause the attribute value to be resolved against the document's base URI (original location): attr("abs:href")

For this use case, it is important to specify the base URI when parsing the document.

If you don't want to use the abs: prefix, there is also a method Node.absUrl(String key) which does the same thing, but accesses via the natural attribute key.

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Jsoup解析HTML實(shí)例及文檔方法詳解
Extract Links From a HTML Page Using Delphi
jsoup 的選擇器一覽表 - 開源中國(guó)社區(qū)
Jsoup選擇器規(guī)則
java簡(jiǎn)單爬蟲----Jsoup
誰說只有Python能寫爬蟲?Javaer 轉(zhuǎn)身甩出這個(gè)框架:給爺爬!
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服