织梦采集文章时不能采集生成TAG及描述的解决办法

2022-08-18

织梦dedecms默认的采集功能只能采集到keywords,不能生成tags标签,采集回来的描述这项也是空的,需要再编辑一下才能生成description内容。
下面介绍一下解决方法:
首先打开后台管理目录的co_export.php文件,在大概第183行的位置找到如下代码:
else if($itemName == 'litpic')
            {
                $litpic = trim($ctag->GetInnerText());
            }
在其下面插入以下代码:
else if($itemName == 'keywords')
            {
                $keywords = trim($ctag->GetInnerText());
            }
            else if($itemName == 'body')
            {
                $body = trim($ctag->GetInnerText());
                $description = cn_substr(html2text($body),150);
                $description = str_replace(' ','',$description);
                $description = addslashes($description);
            }
然后再找到如下代码
$mainSql = str_replace('@sortrank@', $sortrank, $mainSql);
在其下面插入下面这句:
$mainSql = str_replace('@description@', $description, $mainSql);
再找到如下代码:
$rs = $dsql->ExecuteNoneQuery($mainSql);
在其下面插入如下代码:
$tags = InsertTags($keywords, $aid);
修改完成后保存即可。
这样就会在采集的时候,发现原网页上有keywords,采集并导入数据后,就会自动写入TAG,如果本来没有keywords,就留空。description的话不管原网页有没有,都按采集回来的正文自动生成纯文本,不用担心夹杂乱码或者原网页乱七八糟的内容的。

非凡技术导航 优秀网址导航免费网站收录 网站地图

本站收录的网站若侵害到您的利益,请联系我们删除处理

Copyright ©2020 Guojiz V 5.5All Rights Reserved.

备案号 )| 1735737677|