zoukankan      html  css  js  c++  java
  • DEDE采集时自动生成摘要和关键字

    1、修改 include/dedecollection.class.php

    //自动分析关键字和摘要 
    preg_match("/<meta[s]+name=['"]keywords['"] content=['"](.*)['"]/isU",$this->tmpHtml,$inarr); 
    preg_match("/<meta[s]+content=['"](.*)['"] name=['"]keywords['"]/isU",$this->tmpHtml,$inarr2); 
    if(!isset($inarr[1]) && isset($inarr2[1])) 
    { 
    $inarr[1] = $inarr2[1]; 
    }

    用下面一段代码替换上面的

    //自动分析关键字和摘要 
    preg_match("/<meta[s]+name=['"]keywords['"] content=['"](.*)['"]/isU",$this->tmpHtml,$inarr); 
    preg_match("/<meta[s]+content=['"](.*)['"] name=['"]keywords['"]/isU",$this->tmpHtml,$inarr2); 
    preg_match("/<meta[s]+name=keywords content=['"](.*)['"]/isU",$this->tmpHtml,$inarr3); 
    if(!isset($inarr[1]) && isset($inarr2[1])) 
    { 
    $inarr[1] = $inarr2[1]; 
    } 
    if(!isset($inarr[1]) && isset($inarr3[1])) 
    { 
    $inarr[1] = $inarr3[1]; 
    }

    改了上面的, 还有另一个地方需要修改的,网站描述部分

    preg_match("/<meta[s]+name=['"]description['"] content=['"](.*)['"]/isU",$this->tmpHtml,$inarr); 
    preg_match("/<meta[s]+content=['"](.*)['"] name=['"]description['"]/isU",$this->tmpHtml,$inarr2); 
    if(!isset($inarr[1]) && isset($inarr2[1])) 
    { 
    $inarr[1] = $inarr2[1]; 
    }

    用下面的代码替换掉上面的:

    preg_match("/<meta[s]+name=['"]description['"] content=['"](.*)['"]/isU",$this->tmpHtml,$inarr); 
    preg_match("/<meta[s]+content=['"](.*)['"] name=['"]description['"]/isU",$this->tmpHtml,$inarr2); 
    preg_match("/<meta[s]+name=description content=['"](.*)['"]/isU",$this->tmpHtml,$inarr3); 
    if(!isset($inarr[1]) && isset($inarr2[1])) 
    { 
    $inarr[1] = $inarr2[1]; 
    } 
    if(!isset($inarr[1]) && isset($inarr3[1])) 
    { 
    $inarr[1] = $inarr3[1]; 
    }
  • 相关阅读:
    4.0中的并行计算和多线程详解(一)
    Dojo工具包简介
    javascript中event.keyCode
    iText简介(转)
    ServletContext
    java文件加解密算法
    ResultSet 的相关介绍
    spring的AOP的四种实现方式
    java实现文件zip压缩或者解压缩
    Hibernate查询数据的几种方式以及HQL用法及参数的几种使用方法
  • 原文地址:https://www.cnblogs.com/wgphp/p/7782193.html
Copyright © 2011-2022 走看看