L'exemple de cet article indique la façon dont Java acquiert le lien de téléchargement réel du disque réseau de Baidu. Partagez-le pour tout le monde pour votre référence. Les détails sont les suivants:
Il y a toujours un problème.
Le dos <map <string, objet >> Dans le retour comprend: nom de fichier (nom de fichier), URL (adresse de la chaîne réelle)
Httprequest.java est le suivant:
Importation java.io.BufferedReader; net.url; classe publique httprequest {public string getData (string u) exception {string re = "" ""; url = new (u); (Get "); "" ;; ((il = bufferedReader.readline ())! = null) {re + = il + "/ n";} return re;}}
Obtenir la méthode:
Importation java.net.urlencoder; .Jsoup; Objet >> list = new ArrayList <map <string, objet >> (); b = html.indexof ("yundata.getCon"); ("yundata.timestamp = /" "); int time_foot = html.indexof (" yundata.share_uk "); int share_id_head = html.indexof (" yundata. share_id = / ""); yundata.sign "); string signe = html.substring (sig_head, signe_foot); signe = signe.substrin. g (signe.indexof (" / "") + 1, signe.indexof ("/"; ")); String time = html.substring (time_head, time_foot); share_id_foot); b);; )); "Utf-8"); jsonArray = new JSONArray ") +"] "); jsonObject = jsonArray.getjsonObject (0); jsonArray = new JSONArray (jsonObject.getString (List"); ; String SonObject.getString ("app_id"); "+ uk +" & shareId = "+ shareId +" & num = 100 & dir = "+ path +" & order = time & desc = 1 & _ = "+ time +" & bdsSoken = c51077ce0e0e0e31606612a13fbcd4 & chunlei & clientType = 0 & web = 1 & app_id = "+ app_id; string fileListjson = httprequest.getData (url1); system.out.println (filelistjson); jsonArray = new JSONArray (" "[" "+ filelistjson +"]; jsonObject = jSonArray ("[" "+ FileLelistJSON +"]; .getJSonObject (0); JSONArray = new JSONArray;} Final int size = jsonArray.Length (); , objet> (); jsonObject = jsonArray.getjsonObject (i); String fileInfo = httprequest .getData ("http: // pan. baidu.com/api/shardownload? Sign =" + signe + "× tamp =" + time + "& bdsstoken = c51077ce0e3131606612a13fbcd4 & chunlei & clienttype = 0 & web = 1 & app_id = 250528 & encrypt = 0 & product = share & uk = "+ uk +" & primorID = "+ share_id +" & fid_list =% 5b "+ fs_id.get (i) +"% 5d "); jsonArray JSONArray2 = new JSONArray ("[" "+ FileInfo +"]; getString ("errno") .equals ("0")) {JSONArray2 = new JSONArray (JSON_DATA.GETSTRING ("List"); 0); ();} Else {return null;} list.add (map);} liste d'urnes;}}
On espère que cet article est utile à la conception du programme Java de tous.