知乎/百度/微博热搜PHP源码


header('Content-Type:application/json; charset=utf-8');
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : "";
if (empty($type)) {
die(
json_encode(
array(
'success' => false,
'msg' => '参数禁止为空!'
),480)
);
//根据参数自动判断
}elseif($type == "zhihuhot"){
$types = "zhihu";
}elseif($type == "weibohot"){
$types = "weibo";
}elseif($type == "bdhot"){
$types = "baidu";
}else{
die(
json_encode(
array(
'success' => false,
'msg' => '请输入正确的参数!'
),480)
);
}
$types();
//知乎热搜榜解析实例
function zhihu(){
$header = ['User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'];
$json = curl('https://www.zhihu.com/hot',$header);
preg_match('/

发表新评论