新微赢技术网

标题: asp实现文章自动截取关键词 [打印本页]

作者: 林枫    时间: 2009-11-30 00:23
标题: asp实现文章自动截取关键词
代码如下:
<%

'转自:http://www.zzwbn.cn
function createkeyword(byval bestr)
if bestr = "" or isnull(bestr) = true or bestr = "" then createkeyword = "" : exit function
dim strChar,strTmp
For i = 1 To Len(bestr)
strChar = Mid(bestr,i,1)
If (Asc(strChar)>=-24648 And Asc(strChar)<=-23553) Then strTmp = strTmp & Chr(Asc(strChar)+23680) Else strTmp = strTmp & strChar   
Next
bestr = replace(strTmp,chr(32),"")
bestr = replace(bestr,chr(9),"")
bestr = replace(bestr," ","") : bestr = replace(bestr,"^","")
bestr = replace(bestr,"'","") : bestr = replace(bestr,"""","")
bestr = replace(bestr,"~","") : bestr = replace(bestr,"-","")
bestr = replace(bestr,"+","") : bestr = replace(bestr,"*","")
bestr = replace(bestr,"/","") : bestr = replace(bestr,"\","")
bestr = replace(bestr,"|","") : bestr = replace(bestr,".","")
bestr = replace(bestr,"@","") : bestr = replace(bestr,"#","")
bestr = replace(bestr,"$","") : bestr = replace(bestr,"%","")
bestr = replace(bestr,"&","") : bestr = replace(bestr,"!","")
bestr = replace(bestr,"?","") : bestr = replace(bestr,",","")
bestr = replace(bestr,":","") : bestr = replace(bestr,";","")
bestr = replace(bestr,"(","") : bestr = replace(bestr,")","")
bestr = replace(bestr,"{","") : bestr = replace(bestr,"}","")
bestr = replace(bestr,"<","") : bestr = replace(bestr,">","")
bestr = replace(bestr,"[","") : bestr = replace(bestr,"]","")
dim t1,t2,i,c,n,e
randomize timer
for i = 1 to len(bestr)
c = Asc(Mid(bestr,i,1))
if (c >= 65 and c <= 90) or (c >= 97 and c <= 122) or (c >= 48 and c <= 57) then e = "" else e = Chr(44)
if Abs(c) > 127 then n = Int((1) * Rnd + 2) else n = 1
if instr(t1,mid(bestr,i,1)) > 0 and Abs(c) > 127 then t1 = t1 else t1 = t1 & e & mid(bestr,i,n)
next
for i = 0 to ubound(split(t1,","))-1
t2 = t2 & e & split(t1,",")(i)
next
if left(t2,1) = chr(44) then t2 = mid(replace(t2,",,",""),2,len(t2))
createkeyword = t2
end function
%>
其实AC编码我不很懂~其中的24648原是23648
作用是去掉“~!@#¥%……&×()——+”望赐教。




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2