if($_GET[id]<=70 && $_GET[id]){
$con=file_get_contents ("http://book.qq.com/lianzaiindex/sort4/index_".$_GET['id'].".htm");
//echo $con;
$preg = "#<td><a href=\"(.*)\" target=\"_blank\"><strong>(.*)</strong>#iUs";
preg_match_all($preg,$con,$arr);
$time=time();
foreach ($arr[1] as $k=>$v){
echo $v." ".$arr[2][$k]."<br>";
$sql="insert into tmp_url (url,title,addtime) values ('".$v."','".$arr[2][$k]."','$time')";
$db->query($sql);
}
$_GET['id']++;
echo "正在采集www.2cto.com。。。。".$_GET[id];
echo "<script>location.href='stahtml.php?id=".$_GET[id]."'</script>";
}else {
echo "采集結束";
}
摘自 chaojie2009的專欄