public static void main(String[] args) throws HttpException, IOException {
String text1=getRealUrlFromBaiduUrl("http://www.baidu.com/link?url=57aywD0Q6WTnl7XKbIHuE8zWE5epzov3Jk7LtVUL7ck9S0xHQGBfYX8eGeCDJXOXwax11EzY0yPEZ0rbRl4p6K");
System.out.println(text1);
}
public static String getRealUrlFromBaiduUrl(String url) {
Connection.Response res = null;
int itimeout = 60000;
try {
res = Jsoup.connect(url).timeout(itimeout).method(Connection.Method.GET).followRedirects(false).execute();
return res.header("Location");
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
String text1=getRealUrlFromBaiduUrl("http://www.baidu.com/link?url=57aywD0Q6WTnl7XKbIHuE8zWE5epzov3Jk7LtVUL7ck9S0xHQGBfYX8eGeCDJXOXwax11EzY0yPEZ0rbRl4p6K");
System.out.println(text1);
}
public static String getRealUrlFromBaiduUrl(String url) {
Connection.Response res = null;
int itimeout = 60000;
try {
res = Jsoup.connect(url).timeout(itimeout).method(Connection.Method.GET).followRedirects(false).execute();
return res.header("Location");
} catch (IOException e) {
e.printStackTrace();
}
return "";
}