09月22日, 2014 3763次
<?php
//微博热榜
$url="https://m.weibo.cn/api/container/getIndex?containerid=106003type%3D25%26t%3D3%26disable_hot%3D1%26filter_type%3Drealtimehot";
$json = file_get_contents($url);
$obj = json_decode($json,true);
//print_r($obj);
foreach($obj['data']['cards'][0]['card_group'] as $item){
echo $item['desc'] ."||".@$item['desc_extr']."\n";
}快手热榜
抓pcweb首页50个
<?php
$header="User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20200102 Firefox/46.0\r\nCookie: _did=这里用你自己的cookie";
$options['http'] = array(
'method' => "GET",
'header' => $header);
$context = stream_context_create($options);
ini_set('allow_url_fopen','on');
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
$text = file_get_contents("https://www.kuaishou.com/",1,$context);
//方法一
preg_match_all('/<script>window.__APOLLO_STATE__=(.*?);\(function\(\){var s;\(s=document.currentScript(.*?)<\/script>/is',$text,$name);
//print_r($name);
$obj=json_decode($name[1][0]);
print_r($obj);
die();
//方法二
preg_match_all('/,"VisionHotRankItem:(.*?)\":{\"rank\"(.*?)\"hotValue\":\"(.*?)\",\"iconUrl"/is',$text,$name);
print_r($name);抖音热榜api
function get_recommend(){
$url="https://creator.douyin.com/aweme/v1/hotspot/recommend/";
$res=file_get_contents($url);
$res_obj=json_decode($res);
if(!empty($res_obj->all_sentences)){
foreach($res_obj->all_sentences as $item){
print_r($item->word);
echo OPHH;
continue;
}
}
}
暂无留言,赶快评论吧