這段程序是 根據采集到的新聞的標題 數據庫中現有的要害字 匹配 來實現的。只怕會不符合有些朋友的需求。請見諒了!還有,采用這段程序會相應增加一點采集的時間。(我沒具體測量過,但操作中感覺不出處理時間有明顯增加)
怎么實現的呢:把數據表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"))
新聞熱點
疑難解答