night rest, want to get two good movies to see,
looking for a long time did not find the want to see,
The thought of having a personal crawling with the user data, a whim,
nothing to the BT Paradise movie Information Crawl down, the next wide to directly check the database.
can only say that the idle egg aches, haha, can also code under codes ^_^
1. Crawl website HTML source code
<span style= "FONT-SIZE:24PX;" > $url = "www.bttiantang.cc";
$html = Shell_exec ("Curl $url");</span>
2. Get total number of pages, total movie (regular match)
<span style= "FONT-SIZE:24PX;" >preg_match ("/<span class=\" pageinfo\ ">.*?<\/span>/", $html, $pageCount);
Preg_match_all ("/\d{1,10000}/", $pageCount [0], $pageCount);</span>
3. Capture movie information (regular matching information)
<span style= "FONT-SIZE:24PX;" >preg_match ("/\d{4}\/\d{2}\/\d{2}/", $pageInfo [0][$i], $updateTime);
Preg_match ("/<font color=\" #FF6600 \ "> (. *?) <i>/", $pageInfo [0][$i], $movieName);
Preg_match ("/<strong> (\d{1}) <\/strong>/", $pageInfo [0][$i], $movieScore _int);
Preg_match ("/<em class=\" fm\ "> (\d{1}) <\/em>/", $pageInfo [0][$i], $movieScore _decimal);
Preg_match ("/href=\" (. *?) \ "/", $pageInfo [0][$i], $MOVIEURL);
Preg_match ("/<p class=\" Des\ ">" (. *?) <\/p>/", $pageInfo [0][$i], $actor);
</span>
4. Insert database, done
Overall, the speed of the PHP crawl is quite fast, 4min not to capture more than 2w information.
start:01:22:54
End:01:26:11
A screenshot of the database is attached:
attached source code:
<?php $url = "www.bttiantang.cc";
$html = Shell_exec ("Curl $url");
Preg_match ("/<span class=\" pageinfo\ ">.*?<\/span>/", $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 ("/<div class=\" Item cl\ ">.*?<\/DIV>/S", $movieHtml, $pageInfo);
For ($i =0 $i <count ($pageInfo [0]); $i + +) {Preg_match ("/\d{4}\/\d{2}\/\d{2}/", $pageInfo [0][$i], $updateTime);
/******clear ad*****/if (empty ($updateTime)) continue;
/*******************/$updateTime = str_replace ('/', '-', $updateTime [0]); Preg_match ("/<font color=\" #FF6600 \ "> (. *?)
<i>/", $pageInfo [0][$i], $movieName);
/*****same conditions*****/ if (empty ($movieName)) Preg_match ("/<b>" (. *?)
<i>/", $pageInfo [0][$i], $movieName); if (empty ($movieName)) Preg_match ("/<b>" (. *?)
<\/b>/", $pageInfo [0][$i], $movieName);
/************************/$movieName = $movieName [1];
Preg_match ("/<strong> (\d{1}) <\/strong>/", $pageInfo [0][$i], $movieScore _int);
$movieScore _int = $movieScore _int[1];
Preg_match ("/<em class=\" fm\ "> (\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 class=\" Des\ ">" (. *?)
<\/p>/", $pageInfo [0][$i], $actor);
$movieActor = Str_replace ("<em>", "," Str_replace ("</em>", "", $actor [1])); Mysql_unbuffered_queRy ("INSERT INTO Movie" (Name,actor,url,update_ts,score) VALUES (' $movieName ', ' $movieActor ', ' $movieUrl ', <span style
= "White-space:pre" > </span> ' $updateTime ', ' $movieScore '); }}?>
This movie information belongs to from the BT Paradise Crawl, does not involve the confidential information, therefore I do not undertake any legal liability.
If the relevant film information related to your copyright or intellectual property or other interests, please inform, confirm will be deleted as soon as possible.