1. 首页
  2. 系统软件

推荐!调用百度热榜,排行榜,实时热点,热门关键词,榜单热词的小程序

推荐!调用百度热榜,排行榜,实时热点,热门关键词,榜单热词的小程序

大家或许有这样的要求,把百度的榜单内容搬到自己的网站上,充实一下内容,提供更优质的用户体验,其它这个非常简单,程序源码也不长,现在贴在下面,复制后保存成asp文件,放到服务器上就可以了。

访问baidutop.asp?id=top10,获得实时热点排行榜前50名,

访问baidutop.asp?id=weekhotspot,获得七日关注排行榜,

访问baidutop.asp?id=top_keyword,获得今日热门搜索排行榜前50名,

访问baidutop.asp?id=shishuoxinci,获得世说新词排行榜。

以下是源代码:

<%
‘本程序源自网络,由https://www.argb.net编辑整理
‘本程序完全免费共享,实例显示请浏览:http://www.sonovo.net
by=request.querystring(“by”)
if by=”” then
by = “top10”
end if
Response.Expires = 0
Response.expiresabsolute = Now() – 1
Response.addHeader “pragma”, “no-cache”
Response.addHeader “cache-control”, “private”
Response.CacheControl = “no-cache”
Response.Buffer = True
Response.Clear
Server.ScriptTimeOut=999999999
‘采集函数
Function getHTTPPage(url)
If IsNull(url)=True Then
response.Write(“请输入网址!”)
Exit Function
End If
On Error Resume Next
dim http
set http=Server.createobject(“MSXML2.XMLHTTP”)
Http.open “GET”,url,false
Http.send()
if Http.readystate<>4 then
response.Write(“该网页无法访问!”)
exit function
end if
GetHTTPPage=bytesToBSTR(Http.responseBody,”gb2312″)
Set Http=Nothing
If Err.number<>0 then
Response.Write “<div align=’center’><b>服务器获取文件内容出错</b></div>”
Err.Clear
End If
End function
‘字节流转换为字符串
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject(“adodb.stream”)
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Function stripHTML(strHTML)
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = “<\/?[^>]*>”
strOutput = objRegExp.Replace(strHTML, “”)
strOutput = Replace(strOutput, “<“, “&lt;”)
strOutput = Replace(strOutput, “>”, “&gt;”)
strOutput = Replace(strOutput, CHR(32), “&nbsp;”)
strOutput = Replace(strOutput, CHR(9), “&nbsp;”)
strOutput = Replace(strOutput, CHR(34), “&quot;”)
strOutput = Replace(strOutput, CHR(39), “&#39;”)
strOutput = Replace(strOutput, CHR(13), “”)
strOutput = Replace(strOutput, CHR(10) & CHR(10), ” “)
strOutput = Replace(strOutput, CHR(10), ” “)
stripHTML = strOutput
Set objRegExp = Nothing
End Function
Dim Url,title,strhtml,strTmp_bd,strkey
dim objRegExp, Match, Matches,Html,skey
‘截取”上升最快Top50″部分的内容
Url=”http://top.baidu.com/buzz/”&by&”.html”
Html= GetHTTPPage(Url)
Set objRegExp = New Regexp     ‘ 建立正则表达式。
objRegExp.IgnoreCase = True    ‘设置是否区分字符大小写
objRegExp.Global = True        ‘设置全局可用性
objRegExp.Pattern = “(<td class=\””.*””\><a href=\””)(.*)(\””\>)(.*)(<\/a></td>)” ‘ 设置模式。
set Matches = objRegExp.Execute(Html) ‘执行搜索
For i=0 To Matches.count-1      ‘遍历匹配集合
Match = Replace(stripHTML(Match),””,””) ‘格式化html代码
title = title&(Matches(i).SubMatches(3)&”||”) ‘赋值Matches(i).SubMatches(3)内容给title
Next
Set objRegExp = Nothing
title=split(title,”||”)
for i=0 to ubound(title)-1
baidu=baidu&”<a href=’http://www.baidu.com/baidu?cl=3&tn=baidutop10&fr=top1000&wd=”&title(i)&”‘ target=’_blank’>”&title(i)&”</a> <br>”
next
baidu=baidu&”<iframe src=baidutop.asp?id=”&by&” width=0 height=0 scrolling=no frameborder=0>auto</iframe>”
‘生成静态文件
Set Fso = Server.CreateObject(“Scripting.FileSystemObject”)
If Not Fso.FolderExists(Server.MapPath(“/”)) Then
Fso.CreateFolder(Server.MapPath(“/”))
End If
set fw=fso.createtextfile(server.mappath(“/”&date&”.html”),true)
fw.writeline baidu
fw.close
set fr=nothing
set fw=nothing
set fso=nothing
response.Write “已经完成,请打开”&date&”.html页”
%>

原创文章,作者:斑斓网站长,如若转载,请注明出处:https://www.argb.net/recommended-baidu-is-called-hot-list-list-real-time-hot-spots-popular-keywords-list-of-hot-words-applet.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

联系我们

在线咨询:点击这里给我发消息

邮件:admin@argb.net

工作时间:周一至周五,9:30-18:30,节假日休息