采集新闻时,自动添加关键字-风讯CMS教程

来源:模板无忧 作者:lino 更新时间:2006-06-16 点击:

这段程序是 根据采集到的新闻的标题 数据库中现有的要害字 匹配 来实现的。只怕会不符合有些朋友的需求。请见谅了!还有,采用这段程序会相应增加一点采集的时间。(我没具体测量过,但操作中感觉不出处理时间有明显增加)

怎么实现的呢:把数据表Routine中的记录一一取出,到新闻标题中去寻找是否出现。假如出现,就作为要害字。一个新闻可能会有多个要害字。

下面举个例子:采集得的新闻标题为: linux环境下的音频编程 。要害字表中有:linux,音频,编程三个要害字。那么最终该新闻就会有\"linux,音频,编程\"三个要害字了。

OK~~DiY it now!

请先备份

Admin\Collect\MoveNewsToSystem.asp

1、打开Admin\Collect\MoveNewsToSystem.asp,拉到倒数第二页(也就是%>的前一行)把下面的代码拷进去

'************************************
'author:lino
'把标题与要害字表中的记录匹配
'Start
'*************************
Function replaceKeywordByTitle(title)
Dim whereisKeyword,i,theKeywordOnNews
Dim keyword,rsRuleObj,theKeywordS
Set RsRuleObj = Conn.Execute(\"Select * from Routine\")
do while Not RsRuleObj.Eof
keyword = RsRuleObj(\"name\")
whereisKeyword = InStr(Lcase(title),Lcase(keyword))
if(whereisKeyword>0) then
if(theKeywordOnNews=\"\") then
theKeywordOnNews=keyword
else
theKeywordOnNews=theKeywordOnNews&\",\"&keyword
end if
end if
RsRuleObj.MoveNext
loop

'假如keyword的长度大于100,截去过长的
if(len(theKeywordOnNews)>99) then
theKeywordOnNews=left(theKeywordOnNews,99)
end if

replaceKeywordByTitle = theKeywordOnNews
End function
'**********************
'End

2、打开Admin\Collect\MoveNewsToSystem.asp ,找到约107行 或搜索

RsSysNewsObj(\"TxtSource\") = RsNewsObj(\"Source\") ,把下面的代码拷上去

RsSysNewsObj(\"keywords\") =replaceKeywordByTitle(RsNewsObj(\"keywords\"))

相关风讯CMS教程:
最新评论:
loading.. 评论加载中....
发表评论:不能超过250字节,请自觉遵守互联网相关政策法规.
  • 昵称: 验证:

最新风讯CMS教程