[开源]由给定的字符串生成包含百度搜索的关键字链接
由给定的字符串生成包含百度搜索的关键字链接
不是很好用,在网上看到的,现在拿到这来与大家分享一下~~
自己可以看看,然后自己改改,说不定就是一个很好的代码了,不过改好后记得要贴上来与大家分享一下你的成果~~
常见的用途:
1、根据文章的标题,生成本篇文章的关键字列表
2、根据文章的标题,生成本篇文章的关键字描述(稍微修改以下程序即可)
<%
'**************************************************
'函数名:CreateBaiduKeyWord
'作 用:由给定的字符串生成包含百度搜索的关键字链接
'参 数:Constr---要生成关键字的原字符串
'返回值:生成的关键字的链接
'**************************************************
Function CreateBaiduKeyWord(byval Constr,Num)
If Constr="" or IsNull(Constr)=True or Constr="" Then
CreateBaiduKeyWord=""
Exit Function
End If
If Num="" or IsNumeric(Num)=False Then
Num=2
End If
Constr=Replace(Constr,CHR(32),"")
Constr=Replace(Constr,CHR(9),"")
Constr=Replace(Constr," ","")
Constr=Replace(Constr," ","")
Constr=Replace(Constr,"(","")
Constr=Replace(Constr,")","")
Constr=Replace(Constr,"<","")
Constr=Replace(Constr,">","")
Constr=Replace(Constr,"""","")
Constr=Replace(Constr,"?","")
Constr=Replace(Constr,"*","")
Constr=Replace(Constr,"|","")
Constr=Replace(Constr,",","")
Constr=Replace(Constr,".","")
Constr=Replace(Constr,"/","")
Constr=Replace(Constr,"\","")
Constr=Replace(Constr,"-","")
Constr=Replace(Constr,"@","")
Constr=Replace(Constr,"#","")
Constr=Replace(Constr,"$","")
Constr=Replace(Constr,"%","")
Constr=Replace(Constr,"&","")
Constr=Replace(Constr,"+","")
Constr=Replace(Constr,":","")
Constr=Replace(Constr,":","")
Constr=Replace(Constr,"‘","")
Constr=Replace(Constr,"“","")
Constr=Replace(Constr,"”","")
Dim i,ConstrTemp
For i=1 To Len(Constr)
ConstrTemp=ConstrTemp & "<a href='www.baidu.com/s?wd="& Mid(Constr,i,Num) &"&cl=3' target='_blank'><b>"& Mid(Constr,i,Num) & "</b></a> | "
Next
CreateBaiduKeyWord=ConstrTemp
End Function
%>
'**************************************************
'函数名:CreateBaiduKeyWord
'作 用:由给定的字符串生成包含百度搜索的关键字链接
'参 数:Constr---要生成关键字的原字符串
'返回值:生成的关键字的链接
'**************************************************
Function CreateBaiduKeyWord(byval Constr,Num)
If Constr="" or IsNull(Constr)=True or Constr="" Then
CreateBaiduKeyWord=""
Exit Function
End If
If Num="" or IsNumeric(Num)=False Then
Num=2
End If
Constr=Replace(Constr,CHR(32),"")
Constr=Replace(Constr,CHR(9),"")
Constr=Replace(Constr," ","")
Constr=Replace(Constr," ","")
Constr=Replace(Constr,"(","")
Constr=Replace(Constr,")","")
Constr=Replace(Constr,"<","")
Constr=Replace(Constr,">","")
Constr=Replace(Constr,"""","")
Constr=Replace(Constr,"?","")
Constr=Replace(Constr,"*","")
Constr=Replace(Constr,"|","")
Constr=Replace(Constr,",","")
Constr=Replace(Constr,".","")
Constr=Replace(Constr,"/","")
Constr=Replace(Constr,"\","")
Constr=Replace(Constr,"-","")
Constr=Replace(Constr,"@","")
Constr=Replace(Constr,"#","")
Constr=Replace(Constr,"$","")
Constr=Replace(Constr,"%","")
Constr=Replace(Constr,"&","")
Constr=Replace(Constr,"+","")
Constr=Replace(Constr,":","")
Constr=Replace(Constr,":","")
Constr=Replace(Constr,"‘","")
Constr=Replace(Constr,"“","")
Constr=Replace(Constr,"”","")
Dim i,ConstrTemp
For i=1 To Len(Constr)
ConstrTemp=ConstrTemp & "<a href='www.baidu.com/s?wd="& Mid(Constr,i,Num) &"&cl=3' target='_blank'><b>"& Mid(Constr,i,Num) & "</b></a> | "
Next
CreateBaiduKeyWord=ConstrTemp
End Function
%>
调用方法:
<%response.Write(""&CreateBaiduKeyWord("编程论坛",2)&"")%>
出来的结果是:
编程 | 程论 | 论坛 | 坛 |
所以程序还要你自己去修改修改!!