获取蓝奏云有密码和无密码分享的直连地址
By
admin
at 2020-09-15 • 0人收藏 • 2920人看过
感谢:xauto 分享代码
import web.json; import string.html; import web.rest.client; namespace lanzou; class client { ctor(...) { this = ..web.rest.client(...); this.addHeaders = { ["origin"] = "https://www.lanzous.com"; ["Accept-Language"] = "zh-CN,zh;q=0.8"; ["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 Edg/79.0.309.51"; } }; getUrl = function(url, pwd = "") { var data; this.parseResponseResult = λ(s)..string.html(s); // 请求下载页面 var htmlDoc = this.get(url) if (!# pwd) { // 先拿到iframe地址 var iframe = htmlDoc.queryEles(tagName = "iframe"); var url = "https://www.lanzoux.com" + iframe[1].src; // 获取 ajax 请求 data var html = this.get(url) var script = html.queryEles(tagName = "script"); var txt = script[2][1].text; data = ..web.json.parse(..string.match(txt, "<^\/>data\s\:\s(%{})")); } else { //获取 ajax 请求 sign var script = htmlDoc.queryEles(tagName = "script"); var txt = script[3][1].text; var sign = ..string.match(txt, "sign\=(.+)\&"); // 自己构造 ajax 请求 data data = { action = "downprocess"; sign = sign; p = pwd }; } // 请求 ajax 获取跳转地址 this.parseResponseResult = λ(s)..web.json.parse(s); var ajax = this.post("https://www.lanzous.com/ajaxm.php", data) var url = ajax.dom + '/file/' + ajax.url // 请求跳转地址获取302重定向地址 this.parseResponseResult = λ() this._http.location(); return this.get(url) } } //测试代码 (function(){ import console; console.setTitle("Lanzou client test!"); var nopl = "https://www.lanzoux.com/iRwihgmkl0j"; var purl = "https://www.lanzoux.com/i2XAqgmkl1a" var pwd = "AArdio"; var lanzou = client() console.printf('无密码分享链接:\n%s\n', lanzou.getUrl(nopl)) console.printf('有密码分享链接:\n%s', lanzou.getUrl(purl, pwd)) console.pause(true); })()
3 个回复 | 最后更新于 2020-10-04
namespace lanzou; class client { ctor(...) { this = client(...); this.addHeaders = { ["origin"] = _host; ["Accept-Language"] = "zh-CN,zh;q=0.8"; ["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 Edg/79.0.309.51"; } }; getUrl = function(url, pwd) { var data = { action = "downprocess" }; this.parseResponseResult = λ(s) s; if (!pwd) { data.sign = this.api(url, "GET", function(ret) { var src = match(ret, `\d{2}\"\ssrc\=\"(.+)\"\sf`); if (src) return this.api(_host + src, "GET", `data\s\=\s\'(.+)\';`)() })() data.ves = 1; } else { data.sign = this.api(url, "GET", `sign\=(.+)\&p`)() data.p = pwd; } this.parseResponseResult = λ(s) parse(s); var ajax = this.post(_host + "ajaxm.php", data) return this._http.location(ajax.dom + '/file/' + ajax.url); }; getList = function(url, pwd) { this.parseResponseResult = λ(s) s; var data = this.api(url, "GET", function(ret) { var data = parse(match(ret, `<^\/>data\s\:\s(%{})`)) var getValue = λ(s) trim(match(ret, s + "\s\=\s(%'')"), "'") data.t = getValue(data.t) data.k = getValue(data.k) data.pg = 1 return data; })(); if (pwd) data.pwd = pwd this.parseResponseResult = λ(s) parse(s); return this.post(_host + "filemoreajax.php", data) }; getId = function(id) { var url = _host + id; return this.getUrl(url); }; getShare = function(url, pwd) { if (!indexOf(url, "http")) return this.getId(url); if (!!indexOf(url, "/i")) return this.getUrl(url, pwd); if (!!indexOf(url, "/b")) return this.getList(url, pwd); } } namespace client { import web.json; import web.rest.client; trim = ..string.trim; match = ..string.match; parse = web.json.parse; client = web.rest.client; indexOf = ..string.indexOf; _host = "https://www.lanzous.com/" } /**intellisense() lanzou.client = 蓝奏云客户端支持库 lanzou.client() = 创建蓝奏云客户端\n!lanc. !lanc.getUrl(.(url, pwd) = 获取蓝奏云分享直连 !lanc.getList(.(url, pwd) = 获取蓝奏云分享文件夹列表 !lanc.getId(.(id) = 通过 id 获取蓝奏云分享直连 !lanc.getShare(.(url, pwd) = 通过分享链接、Id获取蓝奏云分享直连或文件列表 end intellisense**/ //测试代码 (function() { import console; console.setTitle("Lanzou client test!"); var nopl = "https://www.lanzoux.com/iRwihgmkl0j"; var purl = "https://www.lanzoux.com/i2XAqgmkl1a" var pwd = "AArdio"; var lanzou = client() console.printf('无密码分享链接:\n%s\n', lanzou.getShare(nopl)) console.printf('有密码分享链接:\n%s', lanzou.getShare(purl, pwd)) var list = lanzou.getShare("https://www.lanzous.com/b594057/", "5sfr"); console.dumpJson(list) console.log(lanzou.getShare(list.text[1].id)) console.pause(true); })()
登录后方可回帖
无密码分享sign写到ajaxdata变量里面去了,直接匹配data会获取不到url 直接匹配sign构造data就好了!