织梦DEDECMS采集没有自动生成摘要和关键字的解

网站建设 2022-07-27 09:12www.1681989.com免费网站
织梦 5.6采集到了内容,可没有自动生成摘要和关键字,关键字和摘要都是空的。 可能很多人都遇到了和我一样的问题,在论坛实在没找到好的解决办法,就自己动手去改改文件。废话不多说了。 下面是我的解决办法: 1、修改 clude/dedecollection.class.php //自 […]



织梦5.6采集到了内容,可没有自动生成摘要和关键字,关键字和摘要都是空的。
可能很多人都遇到了和我一样的问题,在论坛实在没找到好的解决办法,就自己动手去改改文件。废话不多说了。
下面是我的解决办法:

1、修改 clude/dedecollection.class.php

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

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

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

改了上面的, 还有另一个地方需要修改的

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

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

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


Copyright © 2016-2025 www.1681989.com 推火网 版权所有 Power by