java版最新获取抖音无水印视频和背景音乐
这个工具已经被我放到我的网站上做成了在线抖音无水印获取工具:
在线地址:http://www.yzcopen.com/video/dywsy
废话不多说先看效果
用到jsoup,自行下载
代码如下:
public static void main(String[] args) throws Exception {
String url1 = "三里屯街拍,祝愿大家高考顺利 https://v.douyin.com/JNDRc6L/ 复制此链接,打开【抖音短视频】,直接观看视频!";
System.out.println(getDyMp4Jsoup(url1));
}
public static Connection getConn(String url) {
return Jsoup.connect(url).userAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1").ignoreContentType(true);
}
public static Map
Map
try {
Connection con = getConn(url);
String recurl = getRedirectURL(con);
String[] rest = recurl.split("video/");
String[] mid = rest[1].split("/");
String rceurl = "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids="+mid[0];
Connection reccon = getConn(rceurl);
Response res = reccon.ignoreContentType(true).timeout(10000).execute();
com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(res.body());
List
Map
Map
Map
String urls = ((List
urls = urls.replace("playwm", "play");
restmap.put("urls", urls);
Map
Map
String uri = play_url.get("uri")+"";
restmap.put("uri", uri);
return restmap;
} catch (Exception e) {
e.printStackTrace();
}
return restmap;
}
/**
* 解析抖音
* @param args
* @throws Exception
* @throws Exception
*/
public static Map
//过滤链接,获取http连接地址
String finalUrl = decodeHttpUrl(url1);
String matchUrl = null;
Map
matchUrl = restmap.get("urls")+"";
Connection connreturl = getConn(matchUrl);
String urlrest = getRedirectURL(connreturl);
System.out.println(urlrest);
System.out.println(restmap.get("uri"));
restmap.put("urlrest", urlrest);
return restmap;
}
private static String getRedirectURL(Connection conn) throws IOException {
return conn.followRedirects(false).timeout(10000).execute().header("location");
}
public static String decodeHttpUrl(String url) {
int start = url.indexOf("http");
int end = url.lastIndexOf("/");
String decodeurl = url.substring(start, end);
return decodeurl;
}