这里推荐一个github上的一个项目,居然可以解锁vip文章和下载文件
源码地址:https://gitcode.com/cuckooplus/csdn_download
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
connection.setRequestProperty("connection", "keep-alive");
connection.setRequestMethod("GET");
connection.setRequestProperty("Cookie", cookie);
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
content.append("\n");
}
in.close();
connection.disconnect();
String allContentPlus = content.toString();
allContentPlus = unicodeToCN(allContentPlus);
allContentPlus = allContentPlus.replace("\\", "");
JSONObject allContentPlusJSON = JSONObject.parseObject(allContentPlus);
JSONObject statusJSON = allContentPlusJSON.getJSONObject("status");
Integer code = statusJSON.getInteger("code");
if (code.equals(0)) {
JSONObject dataJSON = allContentPlusJSON.getJSONObject("data");
String txt = dataJSON.getString("txt");
log.info("获取文档内容成功!");
String resultPro = HttpUtil.get(txt);
return R.ok(resultPro);
} else {
String msg = statusJSON.getString("msg");
log.info("获取文档内容失败:{}", msg);
if("复制全文操作每天不超过100次".equals(msg)){
return R.fail("今天次数已用完,请明天再来!");
}else if("文档不可复制.".equals(msg)){
return R.fail("该文档无法复制,请尝试下载!");
}else {
return R.fail("请检查地址是否复制正确!");
}
标签:allContentPlus,return,String,积分,content,获取,connection,msg,下载
From: https://blog.csdn.net/qq_38113597/article/details/139826464