国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|

服務(wù)器之家 - 編程語(yǔ)言 - JAVA教程 - java獲取百度網(wǎng)盤(pán)真實(shí)下載鏈接的方法

java獲取百度網(wǎng)盤(pán)真實(shí)下載鏈接的方法

2019-12-26 13:38王滔 JAVA教程

這篇文章主要介紹了java獲取百度網(wǎng)盤(pán)真實(shí)下載鏈接的方法,涉及java針對(duì)URL操作及頁(yè)面分析的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了java獲取百度網(wǎng)盤(pán)真實(shí)下載鏈接的方法。分享給大家供大家參考。具體如下:

目前還存在一個(gè)問(wèn)題,同一ip在獲取3次以后會(huì)出現(xiàn)驗(yàn)證碼,會(huì)獲取失敗,感興趣的朋友對(duì)此可以加以完善。

返回的List<Map<String, Object>>  中的map包含:fileName( 文件名),url(實(shí)鏈地址)

HttpRequest.java如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 + "\n";
  }
  return re;
 }
}

獲取方法:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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("};");
  JSONArray jsonArray = new JSONArray("[" + html.substring(a, b + 1)
    + "]");
  JSONObject jsonObject = jsonArray.getJSONObject(0);
  String uk = jsonObject.getString("uk");
  String shareid = jsonObject.getString("shareid");
  String path = URLEncoder.encode(jsonObject.getString("typicalPath"),
    "utf-8");
  jsonArray = new JSONArray("[" + jsonObject.getString("file_list") + "]");
  jsonObject = jsonArray.getJSONObject(0);
  jsonArray = new JSONArray(jsonObject.getString("list"));
  jsonObject = jsonArray.getJSONObject(0);
  String app_id = jsonObject.getString("app_id");
  if (jsonObject.getString("isdir").equals("1")) {
   String url1 = "http://pan.baidu.com/share/list?uk="
     + uk
     + "&shareid="
     + shareid
     + "&page=1&num=100&dir="
     + path
     + "&order=time&desc=1&_="
     + time
     + "&bdstoken=c51077ce0e0e313a16066612a13fbcd4&channel=chunlei&clienttype=0&web=1&app_id="
     + app_id;
   String fileListJson = HttpRequest.getData(url1);
   System.out.println(fileListJson);
   jsonArray = new JSONArray("[" + fileListJson + "]");
   jsonObject = jsonArray.getJSONObject(0);
   jsonArray = new JSONArray(jsonObject.getString("list"));
  }
  final int size = jsonArray.length();
  for (int i = 0; i < size; i++) {
   Map<String, Object> map = new HashMap<String, Object>();
   jsonObject = jsonArray.getJSONObject(i);
   String fileName = jsonObject.getString("server_filename");
   map.put("fileName", fileName);
   fs_id.add(jsonObject.getString("fs_id"));
   String fileInfo = HttpRequest
     .getData("http://pan.baidu.com/api/sharedownload?sign="
       + sign
       + "×tamp="
       + time
       + "&bdstoken=c51077ce0e0e313a16066612a13fbcd4&channel=chunlei&clienttype=0&web=1&app_id=250528&encrypt=0&product=share&uk="
       + uk + "&primaryid=" + share_id + "&fid_list=%5B"
       + fs_id.get(i) + "%5D");
   JSONArray jsonArray2 = new JSONArray("[" + fileInfo + "]");
   JSONObject json_data = jsonArray2.getJSONObject(0);
   if (json_data.getString("errno").equals("0")) {
    jsonArray2 = new JSONArray(json_data.getString("list"));
    json_data = jsonArray2.getJSONObject(0);
    map.put("url", json_data.getString("dlink"));
   } else if (json_data.getString("errno").equals("-20")) {
    return null;
    // String getVerCode();
   } else {
    return null;
   }
   list.add(map);
  }
  return list;
 }
}

希望本文所述對(duì)大家的java程序設(shè)計(jì)有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美午夜在线观看 | 国产精品久久久久久 | 亚洲成人一区二区三区 | 色综合99| 91短视频版在线观看www免费 | 999精品| 中文字幕第一页在线 | 欧美精品一二三 | 久久久国产视频 | 成人h动漫在线看 | 亚洲a网| 奇米一区二区三区 | 久久综合成人精品亚洲另类欧美 | 免费高潮 | 日韩美女一级片 | 狼人综干网 | 免费观看a级毛片在线播放 成人片免费看 | 中文字幕在线观看日本 | 精品成人一区 | 免费日韩精品 | 精品亚洲一区二区三区四区五区 | 成人aaa| 久久久久一区二区三区 | 久久9999 | 欧美日韩中文 | 亚洲免费一区 | 午夜电影网址 | 久久国产99 | 国产精品国产成人国产三级 | 国产成人片| 久久伊人中文字幕 | 中文字幕av一区二区 | 国产高清av在线播放 | 日本中文字幕网 | 久久亚洲视频 | 日韩一区二区三区视频 | 亚洲经典一区 | 日本精品视频一区二区 | 国产成人毛片 | 在线观看国产视频 | 欧美激情在线精品一区二区三区 |