百度推出了主动推送,主动推送您将站点当天新产出链接立即通过此方式推送给百度,以保证新链接可以及时被百度收录。 下面青岛星网跟大家分享:百度主动推送ASP源码。
<script language="JScript" runat="Server"> function toObject(json) { eval("var o=" + json); return o; } </script> <% 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 PostHTTPPage(url,data) dim Http set Http=server.createobject("MSXML2.SERVERXMLHTTP.3.0") Http.open "POST",url,false Http.setRequestHeader "CONTENT-TYPE", "text/plain" Http.send(data) if Http.readystate<>4 then exit function End if PostHTTPPage=bytesToBSTR(Http.responseBody,"utf-8") set http=nothing if err.number<>0 then err.Clear End function sitemap = sitemap& "推送网址1" &vbcrlf '读取数据库,每行一条 sitemap = sitemap& "推送网址2" &vbcrlf sitemap = sitemap& "推送网址3" '百度ASP推送调用方法 xwurl = PostHTTPPage(http://data.zz.baidu.com/urls?site=这里是你的域名&token=这里是准入密钥",sitemap) response.clear json = xwurl Set json = toObject(json) if instr(html,"success")>0 then Response.Write "推送成功 "&json.success&" 条;剩余配额 "&json.remain&" 条" else Response.Write "推送失败!返回代码 => "&html end if Set json = Nothing %>