Response对象具有url()方法,该方法应该为您提供最终的url。所以你可以喜欢
String url = "http://t.co/i5dE1K4vSs";Response response = Jsoup.connect(url).followRedirects(true).execute();System.out.println(response.url())
如果要获取中间重定向,则应关闭跟随重定向,然后检查标题“位置”。例如
String url = "http://t.co/i5dE1K4vSs";Response response = Jsoup.connect(url).followRedirects(false).execute();System.out.println(response.header("location"));
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)