最近本人在玩抖音睡,看到好看的视频想保存下载分享,所以无聊自己写了个脚本,仅供参考学习,请勿用于商业用途!
java版:
public static String urlAnalysisMethod(String url) {
if (isContainChinese(url)) {
url = cuthttpschinese(url);
public static String NewUrlDecode(String url) {
doc = Jsoup.connect(url).timeout(5000).get();
// System.out.println(doc.data());
Elements elem = doc.getElementsByTag("script");
String url1 = elem.toString();
int start = url1.indexOf("playAddr");
url1 = url1.substring(start);
int end = url1.indexOf("\",");
return url1.substring(11, end).replaceAll("playwm", "play");
public static String getCover(String url) {
doc = Jsoup.connect(url).timeout(5000).get();
Elements elem = doc.getElementsByTag("script");
String url1 = elem.toString();
int start = url1.indexOf("cover");
String str = url1.substring(start);
int end = str.indexOf("}");
return str.substring(8, end).replaceAll("\"", "");
public static String getURI(String url) {
HttpClient httpClient = new DefaultHttpClient();
HttpContext httpContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet(url);
// 将HttpContext对象作为参数传给execute()方法,则HttpClient会把请求响应交互过程中的状态信息存储在HttpContext中
HttpResponse response = httpClient.execute(httpGet, httpContext);
HttpHost targetHost = (HttpHost) httpContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
// 获取实际的请求对象的URI,即重定向之后的地址
HttpUriRequest realRequest = (HttpUriRequest) httpContext.getAttribute(ExecutionContext.HTTP_REQUEST);
return (HttpHost) httpContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST)
+ ((HttpUriRequest) httpContext.getAttribute(ExecutionContext.HTTP_REQUEST)).getURI().toString();
httpClient.getConnectionManager().shutdown();
public static boolean isContainChinese(String str) {
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher m = p.matcher(str);
public static String cuthttpschinese(String str) {
int start = str.indexOf("http");
return str.substring(start);
想要成品源码的朋友请联系我,谢谢。