教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php 正则表达式 取标题,关键词,内容代码

php 正则表达式 取标题,关键词,内容代码

发布时间:2016-10-28   编辑:jiaochengji.com
教程集为您提供php 正则表达式 取标题,关键词,内容代码等资源,欢迎您收藏本站,我们将为您提供最新的php 正则表达式 取标题,关键词,内容代码资源
采集在现在的cms中都常常用到哦,下面我们就来看看关于php 正则表达式 取标题,关键词,内容代码源码哦。

//获取标题
  $inarr = array();
  preg_match("/<title>(.*)</title>/isU",$body,$inarr);
  if(isset($inarr[1]))
  {
   $redatas['title'] = $inarr[1];
  }

  //获取关键词
  $inarr = array();
  preg_match("/<meta[s] name=['"]keywords['"] content=['"](.*)['"]/isU",$body,$inarr);
  if(isset($inarr[1]))
  {
   $redatas['keywords'] = cn_substr(html2text($inarr[1]),30);
  }

  //获取摘要
  $inarr = array();
  preg_match("/<meta[s] name=['"]description['"] content=['"](.*)['"]/isU",$body,$inarr);
  if(isset($inarr[1]))
  {
   $redatas['description'] = cn_substr(html2text($inarr[1]),$cfg_auot_description);
  }

  //获取内容
  if($s!='' && $e!='')
  {
   $redatas['body'] = GetHtmlAreaA($s,$e,$body);
   if($redatas['body']!='' && $redatas['description']=='')
   {
    $redatas['description'] = cn_substr(html2text($redatas['body']),$GLOBALS['cfg_auot_description']);
   }
  }
 }
 return $redatas;

您可能感兴趣的文章:
php 正则表达式 取标题,关键词,内容代码
php实现文章中关键词加链接的方法
PHP实现中文全文搜索的原理介绍
如何选择网站关键字
搜索引擎策略总结
PHP中TF-IDF与余弦相似性计算文章相似性
seo页面优化教程
seo优化之企业网站标题怎么定位
如何安装 php scws(分词组件)?
常用正则表达式全集

[关闭]
~ ~