随机抓取新浪微博小视频地址

<?php
$ids = [3881380517,2286908003,1752825395,2656274875,3266943013,1663072851];
$key = array_rand($ids);
$id  = $ids[$key];
$geturl = 'https://weibo.com/ajax/statuses/mymblog?uid=' . $id . '&page=1&feature=0';
 
$result =  get_curl(
    $geturl
    ,0
    ,'https://weibo.com/u/' . $id . '?lpage=profileRecom'
    ,'XSRF-TOKEN=HBrPLdHRfCgCoNaAJDVx6R5B; SUB=_2AkMTNC0Cf8NxqwFRmfgWy2PqZIxyyw3EieKlaNzZJRMxHRl-yT9vqnQCtRB6OLQD7VqVLExFvLzJRwLjpHYx1gN3b66X;'
    ,0
    ,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
    ,0
    ,0
);
$array    =   json_decode($result);
 
$array->data->list[1]->page_info->object_type;
//print_r($array->data->list[1]);
if (!empty($array->data->list[1]->page_info->object_type) && $array->data->list[1]->page_info->object_type == 'video') {
    //print_r($array->data->list[1]->page_info->media_info);
    echo $array->data->list[1]->page_info->media_info->next_title;
    echo PHP_EOL;
    echo $array->data->list[1]->page_info->media_info->stream_url;
}
 
 
/*preg_match_all('/\"mp4_720p_mp4\":\"(.*?)\"/', $result, $matches);
 
print_r($matches);*/
 
/*if (!empty($matches[1])) {
    $key = array_rand($matches[1]);
    $url  = $matches[1][$key];
 
    file_put_contents(__DIR__ . '/下载.mp4', get_curl($url));
}*/
 
function get_curl($url,$post=0,$referer=1,$cookie=0,$header=0,$ua=0,$nobaody=0,$addheader=0)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $httpheader[] = "Accept: application/json";
    //$httpheader[] = "Accept-Encoding: gzip,deflate,sdch";
    $httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
    $httpheader[] = "Connection: close";
    if($addheader){
        $httpheader = array_merge($httpheader, $addheader);
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
    if($post){
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    }
    if($header){
        curl_setopt($ch, CURLOPT_HEADER, TRUE);
    }
    if($cookie){
        curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    }
    if($referer){
        if($referer==1){
            curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=');
        }else{
            curl_setopt($ch, CURLOPT_REFERER, $referer);
        }
    }
    if($ua){
        curl_setopt($ch, CURLOPT_USERAGENT,$ua);
    }else{
        curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Linux; U; Android 4.4.1; zh-cn) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.5 Mobile Safari/533.1');
    }
    if($nobaody){
        curl_setopt($ch, CURLOPT_NOBODY,1);
    }
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_ENCODING, "gzip");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    $ret = curl_exec($ch);
    curl_close($ch);
    //$ret=mb_convert_encoding($ret, "UTF-8", "UTF-8");
    return $ret;
}


微信扫描下方的二维码阅读本文

版权声明:
作者:admin
链接:https://q-sen.cn/%e6%ba%90%e7%a0%81/%e9%9a%8f%e6%9c%ba%e6%8a%93%e5%8f%96%e6%96%b0%e6%b5%aa%e5%be%ae%e5%8d%9a%e5%b0%8f%e8%a7%86%e9%a2%91%e5%9c%b0%e5%9d%80/.html
来源:小全资源网
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>