ACFUN出了个专题:http://www.acfun.tv/a/ac715346 数据刷新是AJAX吗~那就抓一下咯 不会用CURL,直接抓了截取,然后加个大括号给到下面 甜党和咸党一开始颠倒了,所以 $tian其实是咸党数据 $xian其实是甜党数据
对了~豆腐脑必然是咸的呀!!!
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, 'http://www.acfun.tv/vote/getVoteReport.aspx?voteId=3');
- // 设置header
- curl_setopt($curl, CURLOPT_HEADER, 1);
-
- // 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
-
- // 运行cURL,请求网页
- $data = curl_exec($curl);
-
- // 关闭URL请求
- curl_close($curl);
-
- //var_dump($data);
- //echo $data;
- $nw = explode('{', $data);
- $json = '{'.$nw[1];
- $xian = 0;
- $tian = 0;
- $other = 0;
-
- $de_json = json_decode($json);
- //var_dump($de_json);
- //echo '';
- for ($i=1; $i <= 34; $i ) {
- foreach ($de_json as $key => $value) {
- if ($key == 'count_'.$i.'_1') {
- $xian = $value;
- }
- if ($key == 'count_'.$i.'_2') {
- $tian = $value;
- }
- if ($key == 'count_'.$i.'_3') {
- $other = $value;
- }
- }
- }
- echo '咸党:'.$tian;
- echo '';
- echo '甜党:'.$xian;
- echo '';
- echo '其他:'.$other;
复制代码
|