解析< META含量= QUOT;">使用jsoup含量、META、LT、jsoup

2023-09-06 11:44:16 作者:七页

需要帮助提取HTML META标签使用JSOUP的URL值。这里是我的html -

Need help extracting the URL values from HTML META tag using JSOUP. Here is my html -

String html = "<HTML><HEAD><...></...><META ......><META ......><META http-equiv="refresh" content="1;URL='https://xyz.com/login.html?redirect=www.google.com'"></HEAD></HTML>"

输出预计:https://xyz.com/login.html?redirect=www.google.com

Output expected : "https://xyz.com/login.html?redirect=www.google.com"

谁能告诉我该怎么做。谢谢

Can anyone please tell me how to do that. Thanks

推荐答案

假设,它是第一个 META

String html_src = ...

Document doc = Jsoup.parse(html);
Element eMETA = doc.select("META").first();
String content = eMETA.attr("content");
String urlRedirect = content.split(";")[1];
String url = urlRedirect.split("=")[1].replace("'","");