且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Jsoup从相对HTML链接中提取绝对URL?

更新时间:2023-02-23 16:32:08

您需要 元素#absUrl()

String url = dl.select("a").absUrl("href");






您可以顺便缩短选择范围:


You can by the way shorten the select:

Document document = Jsoup.connect(url).get();
Elements links = document.select("div.results dl a");
for (Element link : links) {
    String url = link.absUrl("href");
}