第一:确保访问的页面的编码为本身编码,再用正则表达式获取,否则解析可能出现不全。
第二:确保访问的网页html内的回车,空格和空白去掉,否则解析出错。(win : /r/n或linux : /r)
统一编码: $str_163astro = str_replace("\r\n","", iconv("GB2312", "UTF-8",$str_163astro));
去掉空格的方法: $str_163astro = preg_replace("~\s{2,}~s", "", $str_163astro);
第二:确保访问的网页html内的回车,空格和空白去掉,否则解析出错。(win : /r/n或linux : /r)
统一编码: $str_163astro = str_replace("\r\n","", iconv("GB2312", "UTF-8",$str_163astro));
去掉空格的方法: $str_163astro = preg_replace("~\s{2,}~s", "", $str_163astro);