ACFUN has a special topic: http://www.acfun.tv/a/ac715346 Is data refresh using AJAX? Then grab it I don’t know how to use CURL, so I grabbed the interception directly, and then added curly brackets to the bottom Sweet and salty were reversed at first, so $tian is actually salty data $xian is actually sweet data
By the way~ Tofu must be salty! ! !
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, 'http://www.acfun.tv/vote/getVoteReport.aspx?voteId=3');
- / / Set header
- curl_setopt($curl, CURLOPT_HEADER, 1);
-
- // Set cURL parameters to require the result to be saved in a string or output to the screen.
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
-
- // Run cURL and request the web page
- $data = curl_exec($curl);
-
- // Close URL request
- 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 'Salty Party:'.$tian;
- echo '';
- echo 'Sweet Party:'.$xian;
- echo ' ';
- echo 'Other:'.$other;
Copy code
|