使用java自带的网络连接包进行的请求:
//获取链接重定向后的真实URL
private static String getRedirectUrl(String url) {
HttpURLConnection conn = null;
try {
conn = (HttpURLConnection) new URL(url).openConnection();
conn.getResponseCode();
return conn.getURL().toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (conn != null) {
conn.disconnect();
}
}
return "";
}
参考链接:
https://www.cnblogs.com/zhangj95/p/4196630.html |