网站首页
php采集与过滤
发布时间:2015-12-27 17:05:18编辑:admin阅读()
最经做了一个新闻采集页面,传送入口→lzzit.com/news
有用到了file_get_contents()、str_replace()这些函数!
$huoqq=file_get_contents("http://www.lzzit.com/news");//获取页面字符 $html = iconv("gb2312", "utf-8//IGNORE",$huoqq); //转码 $qian=array(" "," ","\t","\n","\r","更新");$hou=array("","","","","","");//要过滤的字符 $guo_html=str_replace($qian,$hou,$html);//过滤函数 preg_match_all('/<divclass="fl"><span>(.*)<\/span>/iU', $guo_html, $matches_title_qq);//后面的iU是不分大小写的意思