這段程序是 根據(jù)采集到的新聞的標(biāo)題 數(shù)據(jù)庫(kù)中現(xiàn)有的要害字 匹配 來(lái)實(shí)現(xiàn)的。只怕會(huì)不符合有些朋友的需求。請(qǐng)見諒了!還有,采用這段程序會(huì)相應(yīng)增加一點(diǎn)采集的時(shí)間。(我沒具體測(cè)量過(guò),但操作中感覺不出處理時(shí)間有明顯增加)
怎么實(shí)現(xiàn)的呢:把數(shù)據(jù)表Routine中的記錄一一取出,到新聞標(biāo)題中去尋找是否出現(xiàn)。假如出現(xiàn),就作為要害字。一個(gè)新聞可能會(huì)有多個(gè)要害字。
下面舉個(gè)例子:采集得的新聞標(biāo)題為: linux環(huán)境下的音頻編程 。要害字表中有:linux,音頻,編程三個(gè)要害字。那么最終該新聞就會(huì)有"linux,音頻,編程"三個(gè)要害字了。
OK~~DiY it now!
請(qǐng)先備份
Admin/Collect/MoveNewsToSystem.asp
1、打開Admin/Collect/MoveNewsToSystem.asp,拉到倒數(shù)第二頁(yè)(也就是%>的前一行)把下面的代碼拷進(jìn)去
'************************************
'author:lino
'把標(biāo)題與要害字表中的記錄匹配
'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的長(zhǎng)度大于100,截去過(guò)長(zhǎng)的
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"))
新聞熱點(diǎn)
疑難解答