AVFUN Tofu Nao Sweet Party Salty Party Data Statistics

WBOY
Release: 2016-07-25 08:50:44
Original
1217 people have browsed it
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! ! !
  1. $curl = curl_init();
  2. curl_setopt($curl, CURLOPT_URL, 'http://www.acfun.tv/vote/getVoteReport.aspx?voteId=3');
  3. / / Set header
  4. curl_setopt($curl, CURLOPT_HEADER, 1);
  5. // Set cURL parameters to require the result to be saved in a string or output to the screen.
  6. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  7. // Run cURL and request the web page
  8. $data = curl_exec($curl);
  9. // Close URL request
  10. curl_close($curl);
  11. //var_dump( $data);
  12. //echo $data;
  13. $nw = explode('{', $data);
  14. $json = '{'.$nw[1];
  15. $xian = 0;
  16. $tian = 0;
  17. $other = 0;
  18. $de_json = json_decode($json);
  19. //var_dump($de_json);
  20. //echo '
    ';
  21. for ($i=1; $i <= 34; $i++) {
  22. foreach ($de_json as $key => $value) {
  23. if ($key == 'count_'.$i.'_1') {
  24. $xian += $value ;
  25. }
  26. if ($key == 'count_'.$i.'_2') {
  27. $tian += $value;
  28. }
  29. if ($key == 'count_'.$i.'_3') {
  30. $other += $value;
  31. }
  32. }
  33. }
  34. echo 'Salty Party:'.$tian;
  35. echo '
    ';
  36. echo 'Sweet Party:'.$xian;
  37. echo '
    ';
  38. echo 'Other:'.$other;
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!