Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

需要修改蓝奏云获取链接的接口 #7623

Closed
4 tasks done
czkbai2 opened this issue Dec 8, 2024 · 0 comments
Closed
4 tasks done

需要修改蓝奏云获取链接的接口 #7623

czkbai2 opened this issue Dec 8, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@czkbai2
Copy link

czkbai2 commented Dec 8, 2024

Please make sure of the following things

  • I have read the documentation.
  • I'm sure there are no duplicate issues or discussions.
  • I'm sure this feature is not implemented.
  • I'm sure it's a reasonable and popular requirement.

Description of the feature / 需求描述

现在这个接口获取到的链接可以下载,但是在部分地区反诈,直接无法下载,我这边有个可用的php解析代码,可以修改一下,用在go语言解析,下面这个php接口,会解析到两个下载链接,第一个解析的链接和alist解析到一样,第二个则为可正常下载链接

Suggested solution / 实现思路

下面是php部分代码

false, "message" => "请输入需要解析的蓝奏云链接!"); exit(json_encode($result,480)); }elseif (strpos($url,'lanzou') == false) { $result = array("success" => false, "message" => "你输入的不是蓝奏云链接!"); exit(json_encode($result,480)); } //根据传入的蓝奏云链接 自适应获取链接 $urls = parse_url($url); //一个简单的链接处理 if(strstr($url, '.com/tp/')){ //判断是否包含/tp $url = 'https://'.$urls['host'].'/'.explode('.com/tp/',$url)[1]; }else{ $url = 'https://'.$urls['host'].'/'.explode('.com/',$url)[1]; } $softInfo = MloocCurlGet($url); if (strstr($softInfo, "文件取消分享了") != false) { $result = array("success" => false, "message" => "文件取消分享了"); exit(json_encode($result,480)); } //判断是否需要文件分享密码 if(strstr($softInfo, "function down_p(){") != false){ if(empty($pwd)){ $result = array("success" => false, "message" => "请输入文件分享密码!"); exit(json_encode($result,480)); } //正则获取sign preg_match_all("/var\s+skdklds\s*=\s*'([^']+)'/i", $softInfo, $segment); $post_data = array( "action" => 'downprocess', "sign" => $segment[1][0], "p" => $pwd ); $softDownlink = MloocCurlPost($post_data, "https://".$urls["host"]."/ajaxm.php", $url); $softName[1] = json_decode($softDownlink,true)['inf']; preg_match('~
大小:(.*?)
~', $softInfo, $softFilesize); }else{ preg_match('~style="font-size: 30px;text-align: center;padding: 56px 0px 20px 0px;">(.*?)<\/div>~', $softInfo, $softName); preg_match('~文件大小:(.*?)
~', $softInfo, $softFilesize); //正则获取链接 preg_match('/(?/i', $softInfo, $link); //获取到的下载链接 $softDown = MloocCurlGet('https://'.$urls['host'].$link[1]); //正则获取sign //preg_match_all("/var\s+sasign\s*=\s*'([^']+)'/i", $softDown, $downKeyArr); preg_match_all("/'sign':'([^']+)'/i", $softDown, $downKeyArr); //post数据 $post_data = array( "action" => 'downprocess', "signs"=>'?ctdf', "websignkey"=>'Ypvp', "sign" => $downKeyArr[1][0], ); $softDownlink = MloocCurlPost($post_data, "https://".$urls["host"]."/ajaxm.php", $url); } $softDownlink = json_decode($softDownlink,true); $downUrl = $softDownlink['dom'] . '/file/' . $softDownlink['url']; //判断zt值是否为1 if ($softDownlink['zt'] == 1) { $infoArr = array('file_name'=>isset($softName[1]) ? $softName[1] : "",'file_size'=>isset($softFilesize[1]) ? $softFilesize[1] : ""); $result = array("success" => true, 'info' => $infoArr, "download" => $downUrl, "fileUrl" => restoreUrl($downUrl),'copyright'=>$info_copyright); if($type !== 'down'){ exit(json_encode($result,480)); }else{ header("Location:$downUrl"); } } else { $result = array("success" => false, "message" => "文件不存在或获取超时!"); exit(json_encode($result,480)); } //HTTP_Get封装方式 function MloocCurlGet($url = '', $UserAgent = '') { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); if ($UserAgent != "") { curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent); } $ip = rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255); curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip)); #关闭SSL curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); #返回数据不直接显示 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl); curl_close($curl); return $response; } //HTTP_Post封装方式 function MloocCurlPost($post_data = '', $url = '', $ifurl = '', $UserAgent = '') { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent); if ($ifurl != '') { curl_setopt($curl, CURLOPT_REFERER, $ifurl); } $ip = rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255); curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip)); #关闭SSL curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); #返回数据不直接显示 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); $response = curl_exec($curl); curl_close($curl); return $response; } // 连接转换封装 function restoreUrl($shortUrl) { $ip = rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255); $header[] = "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"; $header[] = "accept-encoding: gzip, deflate, br"; $header[] = "accept-language: zh-CN,zh;q=0.9"; $header[] = "cache-control: max-age=0"; $header[] = "sec-ch-ua: \"Google Chrome\";v=\"95\", \"Chromium\";v=\"95\", \";Not A Brand\";v=\"99\""; $header[] = "sec-ch-ua-mobile: ?0"; $header[] = "sec-ch-ua-platform: \"Windows\""; $header[] = "sec-fetch-dest: document"; $header[] = "CLIENT-IP:" . $ip; $header[] = "X-FORWARDED-FOR:" . $ip; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $shortUrl); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36"); //设置UA curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_exec($ch); $info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); curl_close($ch); return $info; } ?>

Additional context / 附件

https://down.szczk.top/d/onedrive/onedrive/lanzou.php?sign=F47CN2wymr4YRrryKrqX-I2es3efmgQuEmqZRaJDcIQ=:0

@czkbai2 czkbai2 added the enhancement New feature or request label Dec 8, 2024
@czkbai2 czkbai2 closed this as completed Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant