(相关资料图)
本教程操作环境:Windows7系统、PHP8.1版、Dell G3电脑。
php怎么只获取文章文字内容?
php只抓取网页body文字内容,并过滤网页标签
php只抓取网页文字内容,并过滤其标签,说干就干,开始!
代码如下:
(.*?)<\/body>/is",$data,$match); $str= trim($match[1]); $html = strip_tags($str); $html_len = mb_strlen($html,"UTF-8"); $html = mb_substr($html, 0, strlen($html), "UTF-8"); $search = array(" "," ","\n","\r","\t"); $replace = array("","","","",""); echo str_replace($search, $replace, $html); }}curl_request ( $url, $post = "" , $cookie = "" , $returnCookie = 0 );?>
登录后复制
推荐学习:《PHP视频教程》
以上就是php怎么只获取文章文字内容的详细内容,更多请关注php中文网其它相关文章!