网站首页
免费技术
源码下载
免费软件
域名空间
活动资讯
值得一看
关于本站
网址导航
您的位置:首页 > 其他技术教程 > 随机抓取新浪微博小视频地址
随机抓取新浪微博小视频地址
2023-7-10    215    0

随机抓取新浪微博指定用户的小视频地址,标题,你问我用途,暂不明,没用上,分享一下。
<?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;
}
上一篇: 竞速游戏 顶尖快艇竞速3D
下一篇: 通过网盘批量白嫖源码网站付费内容脚本