-
-
未解决 【已解决】获取蓝奏云真实链接问题?
-
发表于: 2020-7-22 11:20 2829
-
Java写的:
String html_url = "https://www.lanzous.com/i6cSsepn2aj"; Connection html_head = Jsoup.connect(html_url); html_head.header("Accept", "text/html, application/xhtml+xml, */*"); html_head.header("Content-Type", "application/x-www-form-urlencoded"); html_head.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.3"); html_head.header("referer", html_url); String html2_url = "https://www.lanzous.com"+(html_head.get().select("iframe").first().attr("src")); Elements html2 = Jsoup.connect(html2_url).get().getElementsByTag("script"); String[] data = html2.get(1).data().split("data"); String action = "downprocess"; //参数一 String sign = data[2].substring(data[2].indexOf("sign':")+6, data[2].lastIndexOf(",'ves':1")); //取得参数二 String post_url = "https://www.lanzous.com/ajaxm.php"; Connection post_url_head = Jsoup.connect(post_url); post_url_head.header("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36 OPR/28.0.1750.51"); post_url_head.header("Accept-Encoding","gzip, deflate, lzma, sdch"); post_url_head.header("Accept-Language","zh-CN,zh;q=0.8"); post_url_head.header("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); post_url_head.data("action", action); post_url_head.data("sign", sign); post_url_head.data("ves", "1"); System.out.println(post_url_head.post());
python 写的
#coding=utf-8 from bs4 import BeautifulSoup import requests import re import json #蓝奏云分享文件链接地址 url = 'https://wwa.lanzous.com/i6cSsepn2aj' #header头,注意那个referer必须要与上面文件分享地址url相同 headers = { 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.3', 'referer': url } # 获取分享页面html文件 res = requests.get(url,headers=headers) # 引入BeautifulSoup库对html进行处理,获取iframe中的出现的js文件 soup = BeautifulSoup(res.text,'html.parser') url2 = 'https://www.lanzous.com/'+soup.find('iframe')['src'] res2 = requests.get(url2,headers=headers) # 正则提取请求三个参数 sign = re.findall("\'sign\':(\'.*?\')",res2.text) # 请求下载地址 url3 = 'https://www.lanzous.com/ajaxm.php' data = { 'action':'downprocess', 'sign':sign, 'ves':'1' } res3 = requests.post(url3,headers=headers,data=data) res3 = json.loads(res3.content) # 请求最终重定向地址 url4 = res3['dom']+'/file/'+res3['url'] headers2 = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0', 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', } res4 = requests.head(url4, headers=headers2) print(res4.headers['Location'])
Java输出 的 :
<html> <head></head> <body> {"zt":1,"dom":"https:\/\/vip.d0.baidupan.com","url":"?UzVaZFprBTQACVNrBzJUOFtkBDxTfgJlA3dVPF10B3RVNlZkWnQEflJ+AzwFIVN0UW1TP15tAGcKUgZpBj5SblNhWjtaMwViAG5TMAdiVGxbJwRnU38CPQMzVWpdMAcwVWJWOFo3BHZSdAMlBWxTYFE7U2ReMQAtCj0GNwZ1UmJTa1oiWjMFNQBmUzYHYFRmWzAENVM7AmMDYFVgXTkHMlVtVjZaNARnUjIDbAU0U2NRPFM3XjgAYwo8BmQGY1IwUzBabFopBSsAP1N1B3VUIFtyBGRTfgJpA2BVbl0yBz9VZlY0WjIEY1IiAyEFOFM\/UW5TMF48ADMKPQYwBmpSY1N9WiNaIQU3ADpTcgduVGRbNAQ4UzkCMwM8VWtdMAc1VWJWJ1pyBCBScwNoBWBTZ1EyU2NeMQA0CjwGNwZtUmNTdVp4Wm4FIQBrUzQHa1RmWy8EM1M5AjMDKlVgXTMHKFVgVjA=","inf":0} </body> </html>
但是这个拼起来去访问却显示错误 而且java输出的这个http:\/\/ 为啥是这样的 url里面也有一些,我以为是这个问题,替换回/后也还是错误
python写的不会 py输出的 res3那边
https://dev95.baidupan.com/072211bb/2020/07/18/4d0333147cd384873769e17a9a1d9cca. zip?st=_rC8FZm-Dsl3cvUUkmMk6g&e=1595390428&b=BycMaQV2UDpTc1J2V2RSM1N1CHpXLABvVnU _c&fi=26438519&pid=183-253-32-51&up=
已解决捣鼓两天终于弄好了QWQ没用第三方库都是java内库的
package 蓝奏云; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.regex.Pattern; public class 解析蓝奏云真实地址Api { public static void main(String[] args) { 解析蓝奏云真实地址Api urlapi = new 解析蓝奏云真实地址Api(); String 分享的链接 = "https://wwa.lanzous.com/i1RMXeph65c"; String fn = urlapi.GetURLHtml(分享的链接,"<iframe class=\"ifr2.*",""); fn = "https://www.lanzous.com"+fn.substring(fn.indexOf("/fn"), fn.lastIndexOf("_c")+2); String sign = urlapi.GetURLHtml(fn,"var pposturl.*",""); sign = sign.substring(sign.indexOf("'")+1,sign.lastIndexOf("'")); String data = "action=downprocess&sign="+sign; String 伪地址 = urlapi.PostURLHtml("https://www.lanzous.com/ajaxm.php", data,fn); String dom = 伪地址.substring(伪地址.indexOf("\"dom\"")+7, 伪地址.lastIndexOf("url")-3); String url = 伪地址.substring(伪地址.indexOf("\"url\"")+7, 伪地址.lastIndexOf(",")-1); String 伪直链 = (dom+"/file/"+url).replaceAll("\\\\", ""); String 真实链接ohhh = urlapi.GetURLHtml(伪直链, "", "Location"); System.out.println(真实链接ohhh); } public String GetURLHtml(String url,String matches,String HeaderField){ URL URL; HttpURLConnection url_conn = null; String data; String url_return = null; String HF =null; try { URL = new URL(url); url_conn = (HttpURLConnection) URL.openConnection(); url_conn.setRequestMethod("GET"); //设置请求方式为GET url_conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0"); url_conn.setRequestProperty("Accept-Language","zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); url_conn.setRequestProperty("referer",url); url_conn.setDoInput(true); //是否打开输入流 , 此方法默认为true url_conn.setDoOutput(true); //是否打开输出流, 此方法默认为false url_conn.setUseCaches(false); //取消缓存 url_conn.setInstanceFollowRedirects(false); url_conn.connect(); BufferedReader br = new BufferedReader(new InputStreamReader(url_conn.getInputStream(), "utf-8")); while((data=br.readLine())!=null){ data = data.trim(); if(Pattern.matches(matches, data)){ url_return=data; break; } } HF=url_conn.getHeaderField(HeaderField); //释放资源 br.close(); url_conn.disconnect(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HeaderField != "" ? HF : url_return; } public String PostURLHtml(String php,String data,String Referer){ PrintWriter out=null; String buff2=""; try { URLConnection postconn = new URL(php).openConnection(); postconn.setRequestProperty("accept", "image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/xaml+xml, application/x-ms-xbap, */*"); postconn.setRequestProperty("Accept-Language", "en-us"); postconn.setRequestProperty("user-agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0"); postconn.setRequestProperty("Host", "www.lanzous.com"); postconn.setRequestProperty("Connection", "Keep-Alive"); postconn.setRequestProperty("Referer", Referer); postconn.setDoOutput(true); postconn.setDoInput(true); out = new PrintWriter(postconn.getOutputStream()); out.print(data); out.flush(); BufferedReader br = new BufferedReader(new InputStreamReader(postconn.getInputStream(), "utf-8")); String buff; while ((buff = br.readLine()) != null) { buff2 += buff; } br.close(); } catch (IOException e) { e.printStackTrace(); } return buff2; } }
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
最后于 2020-7-23 11:30
被鸭子咯咯哒编辑
,原因:
赞赏
他的文章
- [求助] qq被冻结 2164
- 【已解决】获取蓝奏云真实链接问题? 2830
- api问题? 2014
- VMware 的问题 2831
- U盘问题 2168
看原图
赞赏
雪币:
留言: