PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php ini_set('max_execution_time', 0); ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); function url_get_contents($url) { $data=NULL; $data=file_get_contents($url); if($data) { preg_match("/<body(.*?)>(.+?)<\/body>/s", $data, $matches); $data=$matches[2]; } return $data; } //lấy danh mục $links='http://kembong.wap.mu/library.php?'; $nguon= url_get_contents($links); $html = $nguon; $inx=0; $tvuid=array();$tvname=array(); preg_match_all("/<a href=\"(.*?)\">(.*?)<\/a>/", $html, $matches, PREG_SET_ORDER); foreach ($matches as $val) { if(stristr($val[1],"cid=")) { $tvuid[$inx]= "" . substr(substr($val[1],strrpos($val[1], '=', -5)),1); $tvname[$inx]="".$val[2]; $inx=$inx+1; } } //echo implode(", ",$tvuid); //echo implode(", ",$tvname); //echo "<br/>"; //lấy tên truyện $i=0;$tvuidx=array();$tvnamex=array(); for($i;$i<count($tvuid);$i++) { $linksx=''; $linksx='http://kembong.wap.mu/library.php?id=cat&cid='.$tvuid[$i].'';$nguonx=''; $nguonx= url_get_contents($linksx); $htmlx = $nguonx; preg_match_all("/<a href=\"(.*?)\">(.*?)<\/a>/", $htmlx, $matchesx, PREG_SET_ORDER); foreach ($matchesx as $valx) { if(stristr($valx[1],"tid=")) { $tvuidx[$i]=$tvuidx[$i]. "" . substr(substr($valx[1],strrpos($valx[1], '=', -7)),1).","; //echo substr(substr($valx[1],strrpos($valx[1], '=', -7)),1); $tvnamex[$i]=$tvnamex[$i]."".$valx[2].","; //echo $valx[2]; } elseif(stristr($valx[1],"dir=")) { $dirid='';$dirid=substr(substr($valx[1],strrpos($valx[1], '=', -7)),1); $linksxs=''; $linksxs='http://kembong.wap.mu/library.php?id=cat&cid='.$tvuid[$i].'&dir='.$dirid.'';$nguonxs=''; $nguonxs= url_get_contents($linksxs); $htmlxs = $nguonxs; preg_match_all("/<a href=\"(.*?)\">(.*?)<\/a>/", $htmlxs, $matchesxs, PREG_SET_ORDER); foreach ($matchesxs as $valxs) { if(stristr($valxs[1],"tid=")) { $tvuidx[$i]=$tvuidx[$i]. "" . substr(substr($valxs[1],strrpos($valxs[1], '=', -7)),1).","; $tvnamex[$i]=$tvnamex[$i]."".$valxs[2].","; } } } } } //echo implode(", ",$tvuidx); //echo implode(", ",$tvnamex); for($y=0;$y<count($tvuid);$y++) { $amind=split(",",$tvuidx[$y]);$aname=split(",",$tvnamex[$y]); for($u=0;$u<count($amind);$u++) { echo $aname[$u]."<br>"; } } ?> </body> </html>
Nguồn: http://cobethoitiet.wap.mu