PHP猫眼票房API源码
[alert class="success"]#(滑稽)有钱的捧个流量啥的,没钱的捧个人场。[/alert]
<?php /*猫眼综合票房排行*/ header('Access-Control-Allow-Origin:*'); header('Content-type:application/json; charset=utf-8'); //调用接口 $json = myCurl('http://piaofang.maoyan.com/second-box'); //获取JSON数据 $data = json_decode($json,true); $time = $data["data"]["updateInfo"]; $list = $data["data"]["list"]; //循环 for($i=0;$i<count($list);$i++){ $messages[] = array('one'=>$list[$i]["movieName"],'two'=>$list[$i]["releaseInfo"],'three'=>$list[$i]["sumBoxInfo"],'four'=>$list[$i]["boxInfo"],'five'=>$list[$i]["boxRate"]); } /* one 影片名称 two 上映时间 three 总票房 four 综合票房(万) five 票房占比 */ $api = array('time'=>$time,'messages'=>$messages); echo json_encode($api,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE); /** * [url=home.php?mod=space&uid=45920]@Return[/url] string * Curl GET */ function myCurl($url){ $ch = curl_init(); // Curl 初始化 $timeout = 30; // 超时时间:30s $ua='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'; // 伪造抓取 UA $ip = mt_rand(11, 191) . "." . mt_rand(0, 240) . "." . mt_rand(1, 240) . "." . mt_rand(1, 240); curl_setopt($ch, CURLOPT_URL, $url); // 设置 Curl 目标 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Curl 请求有返回的值 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // 设置抓取超时时间 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 跟踪重定向 curl_setopt($ch, CURLOPT_REFERER, $url); // 伪造来源网址 curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip)); //伪造IP curl_setopt($ch, CURLOPT_USERAGENT, $ua); // 伪造ua curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); //强制协议为1.0 curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); //强制使用IPV4协议解析域名 $content = curl_exec($ch); curl_close($ch); // 结束 Curl return $content; // 函数返回内容 }
|| 版权声明
作者:大米
链接:https://blog.qqsuu.cn/1930.html
声明:如无特别声明本文即为原创文章仅代表个人观点,版权归《大米博客》所有,欢迎转载,转载请保留原文链接。
作者:大米
链接:https://blog.qqsuu.cn/1930.html
声明:如无特别声明本文即为原创文章仅代表个人观点,版权归《大米博客》所有,欢迎转载,转载请保留原文链接。
THE END
0
二维码
打赏
海报

PHP猫眼票房API源码
[alert class="success"]#(滑稽)有钱的捧个流量啥的,没钱的捧个人场。[/alert]
<?php
/*猫眼综合票房排行*/
header('Access-Control-Allow-Origin:*');
……

共有 0 条评论