最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2015年07月16日 16:30:39   作者:王滔  
這篇文章主要介紹了java獲取百度網(wǎng)盤真實(shí)下載鏈接的方法,涉及java針對(duì)URL操作及頁面分析的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

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

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

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

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 + "\n";
  }
  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("};");
  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
       + "&timestamp="
       + 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ì)有所幫助。

相關(guān)文章

  • Springboot+Redis執(zhí)行l(wèi)ua腳本的項(xiàng)目實(shí)踐

    Springboot+Redis執(zhí)行l(wèi)ua腳本的項(xiàng)目實(shí)踐

    本文主要介紹了Springboot+Redis執(zhí)行l(wèi)ua腳本的項(xiàng)目實(shí)踐,詳細(xì)的介紹Redis與Lua腳本的結(jié)合應(yīng)用,具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-09-09
  • 詳解Java回調(diào)的原理與實(shí)現(xiàn)

    詳解Java回調(diào)的原理與實(shí)現(xiàn)

    回調(diào)函數(shù),顧名思義,用于回調(diào)的函數(shù)?;卣{(diào)函數(shù)只是一個(gè)功能片段,由用戶按照回調(diào)函數(shù)調(diào)用約定來實(shí)現(xiàn)的一個(gè)函數(shù)?;卣{(diào)函數(shù)是一個(gè)工作流的一部分,由工作流來決定函數(shù)的調(diào)用(回調(diào))時(shí)機(jī)。
    2017-03-03
  • mybatis中批量更新多個(gè)字段的2種實(shí)現(xiàn)方法

    mybatis中批量更新多個(gè)字段的2種實(shí)現(xiàn)方法

    當(dāng)我們使用mybatis的時(shí)候,可能經(jīng)常會(huì)碰到一批數(shù)據(jù)的批量更新問題,因?yàn)槿绻粭l數(shù)據(jù)一更新,那每一條數(shù)據(jù)就需要涉及到一次數(shù)據(jù)庫的操作,本文主要介紹了mybatis中批量更新多個(gè)字段的2種實(shí)現(xiàn)方法,感興趣的可以了解一下
    2023-09-09
  • Java日常練習(xí)題,每天進(jìn)步一點(diǎn)點(diǎn)(7)

    Java日常練習(xí)題,每天進(jìn)步一點(diǎn)點(diǎn)(7)

    下面小編就為大家?guī)硪黄狫ava基礎(chǔ)的幾道練習(xí)題(分享)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧,希望可以幫到你
    2021-07-07
  • 可觀測性-Metrics-數(shù)據(jù)庫連接池HikariCP監(jiān)控教程

    可觀測性-Metrics-數(shù)據(jù)庫連接池HikariCP監(jiān)控教程

    這篇文章主要介紹了可觀測性-Metrics-數(shù)據(jù)庫連接池HikariCP監(jiān)控教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • Springboot熱加載JAR包的實(shí)現(xiàn)方法

    Springboot熱加載JAR包的實(shí)現(xiàn)方法

    SpringBoot作為一個(gè)開發(fā)快速、部署方便的微服務(wù)框架,具有自動(dòng)配置、約定優(yōu)于配置的特點(diǎn),能夠極大地提高開發(fā)效率,它提供了豐富的擴(kuò)展點(diǎn),非常適合實(shí)現(xiàn)動(dòng)態(tài)加載Jar包的功能,本文將深入探討如何在SpringBoot應(yīng)用中實(shí)現(xiàn)動(dòng)態(tài)加載Jar包的方案,感興趣的朋友一起看看吧
    2024-04-04
  • 詳解SpringBoot如何實(shí)現(xiàn)緩存預(yù)熱

    詳解SpringBoot如何實(shí)現(xiàn)緩存預(yù)熱

    緩存預(yù)熱是指在 Spring Boot 項(xiàng)目啟動(dòng)時(shí),預(yù)先將數(shù)據(jù)加載到緩存系統(tǒng)(如 Redis)中的一種機(jī)制,下面我們就來看看SpringBoot是如何實(shí)現(xiàn)緩存預(yù)熱的吧
    2024-01-01
  • Springboot自動(dòng)配置與@Configuration配置類詳解

    Springboot自動(dòng)配置與@Configuration配置類詳解

    這篇文章主要介紹了SpringBoot中的@Configuration與自動(dòng)配置,在進(jìn)行項(xiàng)目編寫前,我們還需要知道一個(gè)東西,就是SpringBoot對(duì)我們的SpringMVC還做了哪些配置,包括如何擴(kuò)展,如何定制,只有把這些都搞清楚了,我們?cè)谥笫褂貌艜?huì)更加得心應(yīng)手
    2022-07-07
  • Spring基礎(chǔ)之AOP的概念介紹

    Spring基礎(chǔ)之AOP的概念介紹

    AOP是Spring的關(guān)鍵特性之一,雖然Spring的IOC特性并不依賴于AOP,本文重點(diǎn)介紹AOP編程中的一些術(shù)語,這些術(shù)語不僅僅局限于Spring,它適用于所有的AOP編程,感興趣的朋友一起看看吧
    2022-06-06
  • Spring服務(wù)注解有哪些

    Spring服務(wù)注解有哪些

    這篇文章主要介紹了Spring服務(wù)注解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2016-11-11

最新評(píng)論

四川省| 灵台县| 西宁市| 石首市| 平乡县| 华安县| 黔江区| 专栏| 拜泉县| 松滋市| 塔河县| 确山县| 正宁县| 崇信县| 临湘市| 科尔| 汽车| 繁峙县| 油尖旺区| 彰武县| 尚义县| 股票| 庆阳市| 黑龙江省| 白山市| 汕尾市| 政和县| 门头沟区| 延长县| 肇庆市| 乌拉特前旗| 黄大仙区| 同仁县| 青阳县| 固安县| 建德市| 灵台县| 朔州市| 三亚市| 新巴尔虎右旗| 从江县|