Java版藍奏雲真實地址獲取,支持密碼文件下載
Tools.java
package com.lhr;
import java.io.*;
import java.net.*;
/**
*
* By LiHaoran
* QQ 1079991001
*
*
* */
public class Tools {
private String sign;
private String fn;
public String getUrl(String url){
String result = sendGet(url,"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
result ="https://www.lanzous.com/fn?" + getSubString(result,"src=\"/fn?","\"");
this.fn = result;
return result;
}
public String getUrl2(String url){
String result = sendGet(url,"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
this.sign=getSubString(result,"'sign':'","'");
String returnUrl = "https://www.lanzous.com" + getSubString(result,"url : '","'");
return returnUrl;
}
public String getUrl3(String url){
return getUrl3(url,"");
}
public String getUrl3(String url,String passWord){
String data;
if("".equals(passWord)){
data = "action=downprocess&sign=" + this.sign;
}else{
data = "action=downprocess&sign=" + this.sign + "&p=" + passWord;
}
String result = sendGet(url,"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",data,this.fn);
String returnUrl = "https://www.lanzous.com/" + getSubString(result,"url : '","'");
returnUrl = getSubString(result,"\"dom\":\"","\",") + "/file/" + getSubString(result,"\"url\":\"","\",\"");
return returnUrl;
}
private String getSubString(String text, String left, String right) {
String result = "";
int zLen;
if (left == null || left.isEmpty()) {
zLen = 0;
} else {
zLen = text.indexOf(left);
if (zLen > -1) {
zLen += left.length();
} else {
zLen = 0;
}
}
int yLen = text.indexOf(right, zLen);
if (yLen < 0 || right == null || right.isEmpty()) {
yLen = text.length();
}
result = text.substring(zLen, yLen);
return result;
}
private String sendGet(String url,String ua) {
return sendGet(url, ua,"","");
}
private String sendGet(String url,String ua,String param,String Referer) {
String result = "";
PrintWriter out = null;
BufferedReader in = null;
try {
URL realUrl = new URL(url);
//打開和URL之間的連接
URLConnection connection = realUrl.openConnection();
//設置通用的請求屬性
connection.setRequestProperty("accept", "image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*");
connection.setRequestProperty("Accept-Language", "en-us");
connection.setRequestProperty("user-agent",ua);
connection.setRequestProperty("Host", "www.lanzous.com");
connection.setRequestProperty("Connection", "Keep-Alive");
if(!"".equals(Referer)){
connection.setRequestProperty("Referer", Referer);
}
if(!"".equals(param)){
connection.setDoOutput(true);
connection.setDoInput(true);
out = new PrintWriter(connection.getOutputStream());
out.print(param);
out.flush();
}
//建立實際的連接
connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
}catch(Exception e) {
//發送異常
return "發送失敗,請檢查URL地址是否正確";
}finally{
try{
if(in != null){
in.close();
}
}catch(Exception e2) {
//關閉異常
System.out.println("關閉異常");
}
}
return result;
}
}
關於密碼文件的下載:
這是我自己的藍奏雲網盤的文件:
在Demo.java中輸入訪問密碼:
運行結果,得到真實地址:
藍奏雲真實地址為:https:\/\/vip.d0.baidupan.com/file/?BmABP1loADFUXQE5ATQHa1FuATlVR1Q\/ViMDd1FiVCdTDFRHCjsDNAgBAgMCP1c4AGkHLFA\/UX0FcFo9AS9XcAZgAT9ZaAAxVF0BPgExBztRPAE1VTlUYFZnAzVRPlRzUzVUcApqA2AIZwJtAm9XZgBiBzpQOVF1BXJaLAFgV2QGNgFnWT0Ae1QyAWUBegc0UTgBK1U9VDBWYgNkUTVUMFNmVDQKMwNmCG8CZAJhVzIAagdhUDtRZwVmWmwBaVdjBjABY1k0AGRUOwFkATQHYFFtATVVJFQkVjADd1ErVCBTIFRmCiUDPgg6AmkCZVdgAGgHNlA7UWoFJFooATRXOwZjATBZOQBlVDcBYQFlBzVRPwExVTJUblZgAytRIw==
把鏈接復制到IDM中即可開始下載:
IDEA項目已打包上傳到碼雲和藍奏雲
碼雲鏈接:https://gitee.com/lhr0321/20175318_JAVA/tree/master/LanZouYun
藍奏雲鏈接:https://www.lanzous.com/i4jlpaj