分类: |
- 1
百度链接提交主动推送ASP/PHP代码
作者:admin 日期:2015-08-18
链接推送是最为快速的提交提交链接的方式,百度建议您将站点当天新产出链接立即通过此方式推送给百度,以保证新链接可以及时被百度收录。
这里给出两段代码,分别用asp和php将您网站上新产生的链接推送给百度。
asp代码
sub noticeBaidu(article_url)
dim http, url, body, responseText
body = article_url
url = "http://data.zz.baidu.com/urls?site=这里修改为你自己的网址&token=这里修改为你自己的推送KEY"
set http=server.createobject("MSXML2.XMLHTTP")
http.open "POST", url, false
http.setRequestHeader "User-Agent", "request"
http.setRequestHeader "Content-Type", "text/plain"
http.send(body)
" response.write(http.readystate)
responseText = http.responseText
response.write("notice response: " & responseText)
set http = nothing
end sub
php代码
<?php
$urls = array(
"http://www.zeroplace.cn/article.asp?id=960',
'http://www.zeroplace.cn/article.asp?id=961',
);
$api = 'http://data.zz.baidu.com/urls
site=这里修改为你自己的网站&token=这里修改为你自己的推送KEY';
$ch = curl_init();
$options = array(
CURLOPT_URL => $api,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => implode("\n", $urls),
CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;
判断是否为搜索引擎蜘蛛
作者:admin 日期:2010-08-24
<%
function GetBot()
'查询蜘蛛
dim s_agent
GetBot=""
s_agent=Request.ServerVariables("HTTP_USER_AGENT") ‘关键判断语句
if instr(1,s_agent,"googlebot",1) >0 then
GetBot="google"
end if
if instr(1,s_agent,"msnbot",1) >0 then
GetBot="MSN"
end if
if instr(1,s_agent,"slurp",1) >0 then
GetBot="Yahoo"
end if
if instr(1,s_agent,"baiduspider",1) >0 then
GetBot="baidu"
end if
if instr(1,s_agent,"sohu-search",1) >0 then
GetBot="Sohu"
end if
if instr(1,s_agent,"lycos",1) >0 then
GetBot="Lycos"
end if
if instr(1,s_agent,"robozilla",1) >0 then
GetBot="Robozilla"
end if
end function
if GetBot="baidu" then
'给百度定制的内容
elseif GetBot="google" then
'给google 定制的内容
end if
%>
function GetBot()
'查询蜘蛛
dim s_agent
GetBot=""
s_agent=Request.ServerVariables("HTTP_USER_AGENT") ‘关键判断语句
if instr(1,s_agent,"googlebot",1) >0 then
GetBot="google"
end if
if instr(1,s_agent,"msnbot",1) >0 then
GetBot="MSN"
end if
if instr(1,s_agent,"slurp",1) >0 then
GetBot="Yahoo"
end if
if instr(1,s_agent,"baiduspider",1) >0 then
GetBot="baidu"
end if
if instr(1,s_agent,"sohu-search",1) >0 then
GetBot="Sohu"
end if
if instr(1,s_agent,"lycos",1) >0 then
GetBot="Lycos"
end if
if instr(1,s_agent,"robozilla",1) >0 then
GetBot="Robozilla"
end if
end function
if GetBot="baidu" then
'给百度定制的内容
elseif GetBot="google" then
'给google 定制的内容
end if
%>
- 1