Avfun Tofu Brain Sweet Party salt Party data statistics

Source: Internet
Author: User
Acfun a special topic: http://www.acfun.tv/a/ac715346
Data Refresh is Ajax ~ Well, grab a little bit.
Don't use curl, just grab the intercept, and then add a brace to the bottom.
The sweet party and the salty party turned upside down, so
$tian is actually salty party data
$xian is actually sweet party data

Yes ~ Tofu brain 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. Sets the curl parameter, which requires the result to be saved to a string or output to the screen.
  6. curl_setopt ($curl, Curlopt_returntransfer, 1);
  7. Run Curl, request a 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 <=; $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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.