Capture the album name of all users in Sohu video

Source: Internet
Author: User
Capture the album name of all users in Sohu video. If the records are all obtained, it is convenient to retrieve the relevant keywords of the video album. But because the number of users is too many, a thread runs without knowing how many years to run. Multi-channel simultaneous fetching can be achieved by setting multiple tables and ID segments.

Multiple channels can be segmented simultaneously by modifying the start and end of the $user_id.

Sleep (1) is for personal testing only and can be modified
  1. Header ("content-type:text/html; Charset=utf-8 ");
  2. Set_time_limit (0);
  3. $col _title = ";//Title
  4. $col _url = ";//url number
  5. $user _id = 26;//Start Crawl user number
  6. MySQL Pre-operation
  7. $mysqli = new Mysqli ("P:localhost", ' Root ', ' ', ' sohutv ');
  8. if ($mysqli->connect_errno) {
  9. printf ("Connect failed:%s\n", $mysqli->connect_error);
  10. Exit ();
  11. }
  12. $mysqli->set_charset ("UTF8");
  13. $sql = "INSERT into album (Userid,title,url) VALUES (?,?,?)";
  14. $stmt = $mysqli->prepare ($sql);
  15. $stmt->bind_param ("SSS", $user _id, $col _title, $col _url);
  16. Loop crawl
  17. while (true) {
  18. $url = "http://my.tv.sohu.com/user/a/playlist/ta/list.do?userId=". $user _id;
  19. $temp _html = file_get_contents ($url);
  20. $temp _json = Json_decode ($temp _html);
  21. $column _no = $temp _json->{' data '}->{' count '};
  22. if ($column _no) {
  23. Var_dump ($temp _json->{' data '});
  24. $temp _array = $temp _json->{' data '}->{' list '};
  25. for ($i =0; $i < $column _no; $i + +)
  26. {
  27. $temp _obj = $temp _array[$i];
  28. Var_dump ($temp _obj);
  29. $col _title = $temp _obj->{' title '};
  30. $col _url = substr ($temp _obj->{' url '}, 25,-6);
  31. $stmt->execute ();
  32. }
  33. }
  34. Sleep 1 seconds
  35. Sleep (1);
  36. $user _id++;
  37. }
  38. /*
  39. Access mode
  40. Http://my.tv.sohu.com/pl/URL number. shtml
  41. */
  42. ?>
Copy Code
  • Related Article

    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.