SOURCE

console 命令行工具 X clear

                    
>
console
<?php


//$id = $_GET['id'] ?? '';
$url="https://note.youdao.com/s/X90sTxsc";
$res = MloocCurl($url,"get","","");
//echo $res;
//preg_match('id=(.+?)\>',$res,$id);
$id = getSubstr($res,'id=','"');
//$id="39f32a538672db254ffafc4e816ac113";

//echo $id;
if (empty($id)) {
    exit('缺少有道云分享id');
} else {
	//echo $id;
	//echo "\r\n-----------\r\n";
}

$url = "http://note.youdao.com/yws/public/note/{$id}?editorType=0&cstk=cGtjFpHb";
$res = file_get_contents($url);
//echo "\r\n-----------\r\n";
//echo $res;
//echo "\r\n-----------\r\n";
$resArr = json_decode($res, true);
$p = trim($resArr['p'], '/');

$downUrl = "http://note.youdao.com/yws/api/personal/file/{$p}?method=download&inline=true&shareKey={$id}";

echo  $downUrl ;


//此函数解决重定向链接
function MloocCurl($url,$method,$ifurl,$post_data){
$UserAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.2883.87 Safari/537.36';#设置ua
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
if ($method == "post") {
curl_setopt($curl, CURLOPT_REFERER, $ifurl);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
}
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
/*以下是取中间文本的函数  
  getSubstr=调用名称 
  $str=预取全文本  
  $leftStr=左边文本 
  $rightStr=右边文本 
*/ 
function getSubstr($str, $leftStr, $rightStr) 
{ 
    $left = strpos($str, $leftStr); 
    //echo '左边:'.$left; 
    $right = strpos($str, $rightStr,$left); 
    //echo '<br>右边:'.$right; 
    if($left < 0 or $right < $left) return ''; 
    return substr($str, $left + strlen($leftStr), $right-$left-strlen($leftStr)); 
} 
?>