更新(不区分大小写且相当容错)
- 根据规范(几乎)解析内容
- 在首次成功解析的内容元数据,应使用
public static void main(String[] args) throws Exception { URI uri = URI.create("http://www.amerisourcebergendrug.com"); document d = Jsoup.connect(uri.toString()).get(); for (Element refresh : d.select("html head meta[http-equiv=refresh]")) { Matcher m = Pattern.compile("(?si)\d+;\s*url=(.+)|\d+") .matcher(refresh.attr("content")); // find the first one that is valid if (m.matches()) { if (m.group(1) != null) d = Jsoup.connect(uri.resolve(m.group(1)).toString()).get(); break; } }}正确输出:
http://www.amerisourcebergendrug.com/abcdrug/
旧答案:
您确定它不起作用吗?为了我:
System.out.println(Jsoup.connect("http://www.ibm.com").get().baseUri());..
http://www.ibm.com/us/en/正确输出..



