您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Jsoup重定向到URL

Jsoup重定向到URL

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"));

如果它具有多个重定向,则需要递归调用URL。

其他 2022/1/1 18:13:57 有454人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶