想对星座测试进行采集 http://roll.astro.sina.com.cn/t/aqcs/index.shtml 这是新浪的测试题目,我想采集这些问题,答案,哪位高手给我个采集这种的方法和思路 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //一共有34页if(isset($_GET['i']) && !empty($_GET['i'])){ $i = trim($_GET['i']); $i < 34 ? $i++ : $i ; $url = "http://roll.astro.sina.com.cn/t/aqcs/index_$i.shtml" ;}else{ $i = 1 ; $url = "http://roll.astro.sina.com.cn/t/aqcs/index_$i.shtml" ;}echo "正在采集第$i页<br />\n";$content = file_get_contents($url);if(preg_match_all('/<li><a\s+href="(.*?)"[^>]*>(.*?)<\/a>/is',$content,$arr)){ // print_r($arr[1]) ;//地址 // print_r($arr[2]) ;//标题 foreach($arr[1] as $k=>$v){ //$arr[1][$k] 是地址,$arr[2][$k] 是标题 //做入库处理 }}if($i == 34){ echo "<script>alert('采集完成');window.location.href=\"xxxx.php\"</script>"; exit;}else{ echo "<script>window.location.href=\"this.php?i=$i\"</script>";} 最后一点分,请教一个数据库链接问题 請問現的市場是用ASP.NET多還是用PHP的多呢? 如何在页面添加mysql数据库字段 在类里怎样调用外部函数 服务器要怎么开启socket_connect函数啊 网站无法安装 cookie问题与php.ini。。。奇怪 有哪位用过SMARTY吗?进来讨论讨论 哪个知道如google等搜索引擎,如何能搜到数据库的信息呢? 请问如何获得客户端真实IP地址,即使是通过代理服务器上来的! 请问:一个http:错误,英雄,帮我! 帮看看 php文件操作
if(isset($_GET['i']) && !empty($_GET['i'])){
$i = trim($_GET['i']);
$i < 34 ? $i++ : $i ;
$url = "http://roll.astro.sina.com.cn/t/aqcs/index_$i.shtml" ;
}else{
$i = 1 ;
$url = "http://roll.astro.sina.com.cn/t/aqcs/index_$i.shtml" ;
}
echo "正在采集第$i页<br />\n";
$content = file_get_contents($url);
if(preg_match_all('/<li><a\s+href="(.*?)"[^>]*>(.*?)<\/a>/is',$content,$arr)){
// print_r($arr[1]) ;//地址
// print_r($arr[2]) ;//标题
foreach($arr[1] as $k=>$v){
//$arr[1][$k] 是地址,$arr[2][$k] 是标题
//做入库处理
}
}
if($i == 34){
echo "<script>alert('采集完成');window.location.href=\"xxxx.php\"</script>";
exit;
}else{
echo "<script>window.location.href=\"this.php?i=$i\"</script>";
}