作者:oDavid_仔o_880 | 2022-12-01 11:38
本文实例讲述了java获取百度网盘真实下载链接的方法。分享给大家供大家参考。具体如下:
目前还存在一个问题,同一ip在获取3次以后会出现验证码,会获取失败,感兴趣的朋友对此可以加以完善。
返回的List
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
希望本文所述对大家的java程序设计有所帮助。