Capture the album names of all users in Sohu Video
Release: 2016-07-25 08:47:03
Original
1074 people have browsed it
Capture the album names of all users in Sohu Video. If all the records are obtained, video albums with related keywords can be easily retrieved. But because there are too many users, one thread will run for who knows how many years. You can achieve simultaneous capture of multiple channels by setting up multiple tables and ID segments.
You can segment multiple channels at the same time by modifying the start and end of $user_id.
sleep(1) is only for personal testing and can be modified
- header("Content-Type:text/html; Charset=UTF-8");
- set_time_limit(0);
- $col_title = ''; //Title
- $col_url = ' '; //URL number
- $user_id = 26; //Start fetching user number
- //MySQL pre-operation
- $mysqli = new mysqli("p:localhost", 'root', '', 'sohutv' );
- if ($mysqli->connect_errno) {
- printf("Connect failed: %sn", $mysqli->connect_error);
- exit();
- }
- $mysqli->set_charset("utf8" );
- $sql = "INSERT INTO album (userid,title,url) VALUES(?,?,?)";
- $stmt = $mysqli->prepare($sql);
- $stmt->bind_param( "sss",$user_id ,$col_title ,$col_url);
-
-
-
- //Loop capture
- while (true) {
- $url = "http://my.tv.sohu.com/user/a/ playlist/ta/list.do?userId=".$user_id;
- $temp_html = file_get_contents($url);
- $temp_json = json_decode($temp_html);
- $column_no = $temp_json->{'data'}- >{'count'};
-
- if ($column_no) {
- //var_dump($temp_json->{'data'});
- $temp_array = $temp_json->{'data'}-> {'list'};
-
- for($i=0; $i<$column_no; $i++)
- {
- $temp_obj = $temp_array[$i];
- //var_dump($temp_obj);
- $col_title = $temp_obj->{'title'};
- $col_url = substr($temp_obj->{'url'}, 25, -6);
-
- $stmt->execute();
- }
- }
- //Sleep for 1 second
- sleep(1);
- $user_id++;
- }
-
- /*
- Access method
- http://my.tv.sohu.com/pl/URL number.shtml
- */
-
- ?> ;
Copy code
|
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31