/*** 匹配任意id的html标签内容* */function getwebtag($tag_id,$tag='div',$data=false){ $charset_pos = stripos($data,'charset'); if($charset_pos) { if(stripos($data,'utf-8',$charset_pos)) { $data = iconv('utf-8','utf-8',$data); }else if(stripos($data,'gb2312',$charset_pos)) { $data = iconv('gb2312','utf-8',$data); }else if(stripos($data,'gbk',$charset_pos)) { $data = iconv('gbk','utf-8',$data); } } preg_match_all('/$pre_div){ //
调用示例
$html=file_get_contents('http://www.baidu.com');
$divcontent=getwebtag('id=content','div',$html);
$html=file_get_contents('http://www.baidu.com');
$divcontent=getwebtag('id=content','div',$html);
其它类似信息
