: This article mainly introduces how to capture BT paradise movie data. For more information about PHP tutorials, see.
Take a rest in the evening. I want to watch two nice movies,
I couldn't find what I was looking for a long time,
Think of user data that I had previously learned,
It's okay to crawl the movie information from BT Paradise,You can directly query the database next time.
It can only be said to be idle.Haha, you can also code the code ^_^
1. capture the website html source code
$url = "www.bttiantang.cc";$html = shell_exec("curl $url");
2. get the total number of pages and the total number of movies (regular match)
preg_match("/.*?<\/span>/", $html, $pageCount);preg_match_all("/\d{1,10000}/",$pageCount[0],$pageCount);
3. capture movie information (regular match information)
preg_match("/\d{4}\/\d{2}\/\d{2}/" , $pageInfo[0][$i], $updateTime);preg_match("/(.*?)/" , $pageInfo[0][$i], $movieName); preg_match("/(\d{1})<\/strong>/" , $pageInfo[0][$i], $movieScore_int); preg_match("/(\d{1})<\/em>/" , $pageInfo[0][$i], $movieScore_decimal); preg_match("/href=\"(.*?)\"/" , $pageInfo[0][$i], $movieUrl); preg_match("/(.*?)<\/p>/" , $pageInfo[0][$i], $actor);
4. Insert the database.In general, php crawls faster than 4 minutes and collects more than 2 million pieces of information.
Start: 01: 22: 54
End: 01: 26: 11
Attached database:
Source code:
/", $html, $pageCount);preg_match_all("/\d{1,10000}/",$pageCount[0],$pageCount);$pageSize = intval($pageCount[0][0]);$movieCount = $pageCount[0][1];$conn = mysql_connect('***','***','');mysql_select_db('***',$conn);mysql_query('set names utf8',$conn);for($j=1;$j<=$pageSize;$j++){ $movieHtml = shell_exec("curl $url?PageNo=$j"); preg_match_all("/.*?<\/p>/s", $movieHtml, $pageInfo); for($i=0;$i
/" , $pageInfo[0][$i], $movieName); /*****same conditions*****/ if(empty($movieName)) preg_match("/
(.*?)/" , $pageInfo[0][$i], $movieName); if(empty($movieName)) preg_match("/(.*?)<\/b>/" , $pageInfo[0][$i], $movieName); /************************/ $movieName = $movieName[1]; preg_match("/(\d{1})<\/strong>/" , $pageInfo[0][$i], $movieScore_int); $movieScore_int = $movieScore_int[1]; preg_match("/(\d{1})<\/em>/" , $pageInfo[0][$i], $movieScore_decimal); $movieScore_decimal = $movieScore_decimal[1]; $movieScore = floatval($movieScore_int.'.'.$movieScore_decimal); preg_match("/href=\"(.*?)\"/" , $pageInfo[0][$i], $movieUrl); $movieUrl = $movieUrl[1]; preg_match("/
(.*?)<\/p>/" , $pageInfo[0][$i], $actor); $movieActor = str_replace("",'',str_replace("",'',$actor[1])); mysql_unbuffered_query("insert into movie (name,actor,url,update_ts,score) values ('$movieName','$movieActor','$movieUrl','$updateTime','$movieScore')"); }}?>
The information of this film is captured from BT heaven and does not involve confidential information. Therefore, I am not liable for any legal liability!
If the information about the relevant movies involves your copyright, intellectual property or other interests, please inform us that the information will be deleted as soon as possible after confirmation.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above describes how to capture BT paradise movie data, including content, and hope to be helpful to friends who are interested in PHP tutorials.