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