没有合适的资源?快使用搜索试试~ 我知道了~
首页java获取百度网盘真实下载链接的方法
资源详情
资源评论
资源推荐

java获取百度网盘真实下载链接的方法获取百度网盘真实下载链接的方法
主要介绍了java获取百度网盘真实下载链接的方法,涉及java针对URL操作及页面分析的相关技巧,具有一定参考
借鉴价值,需要的朋友可以参考下
本文实例讲述了java获取百度网盘真实下载链接的方法。分享给大家供大家参考。具体如下:
目前还存在一个问题,同一ip在获取3次以后会出现验证码,会获取失败,感兴趣的朋友对此可以加以完善。
返回的List<Map<String, Object>> 中的map包含:fileName( 文件名),url(实链地址)
HttpRequest.java如下:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpRequest {
public static String getData(String u) throws Exception {
String re="";
URL url = new URL(u);
HttpURLConnection httpURLConnection = (HttpURLConnection) url
.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setDoInput(true);
httpURLConnection.setDoOutput(true);
InputStream is = httpURLConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader bufferedReader = new BufferedReader(isr);
String iL = "";
while ((iL = bufferedReader.readLine()) != null) {
re += iL + "";
}
return re;
}
}
获取方法:
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class BaiduNetDisk {
public static List<Map<String, Object>> getUrl(String url) throws Exception {
List<String> fs_id = new ArrayList<String>();
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Document doc = Jsoup.connect(url).get();
String html = doc.toString();
int a = html.indexOf("{\"typicalPath");
int b = html.indexOf("yunData.getCon");
int sign_head = html.indexOf("yunData.SIGN = \"");
int sign_foot = html.indexOf("yunData.TIMESTAMP");
int time_head = html.indexOf("yunData.TIMESTAMP = \"");
int time_foot = html.indexOf("yunData.SHARE_UK");
int share_id_head = html.indexOf("yunData.SHARE_ID = \"");
int share_id_foot = html.indexOf("yunData.SIGN ");
String sign = html.substring(sign_head, sign_foot);
sign = sign.substring(sign.indexOf("\"") + 1, sign.indexOf("\";"));
String time = html.substring(time_head, time_foot);
time = time.substring(time.indexOf("\"") + 1, time.indexOf("\";"));
String share_id = html.substring(share_id_head, share_id_foot);
share_id = share_id.substring(share_id.indexOf("\"") + 1,
share_id.indexOf("\";"));
System.out.println(share_id);
html = html.substring(a, b);
a = html.indexOf("{\"typicalPath");
b = html.indexOf("};");



















安全验证
文档复制为VIP权益,开通VIP直接复制

评论1