对不起,本站需要开启Javascript;请您打开该功能

百度推送可以让你发布的东西直接推送给百度蜘蛛,让其快速收录,百度官方给出了很多范例知道,但是没有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& "www.xionganshanghui.com" &vbcrlf        '读取数据库,每行一条
sitemap = sitemap& "www.xionganshanghui.com/news.asp" &vbcrlf   
html = PostHTTPPage("http://data.zz.baidu.com/urls?site=www.xionganshanghui.com&token=9gXfHvl9V0w4sT2m",sitemap)
Response.Write html
response.clear
json = html
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
%>


咨询
微信扫码咨询
电话咨询
17397907326