aspcms免费开源企业网站开发建设管理系统源码程序

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

asp教程第六课ASP识别搜索引擎蜘蛛的代码(谷歌、百度、雅虎、搜狐、MSN) ...

2021-5-1 21:08| 发布者: 问题发布与回答| 查看: 499| 评论: 0

摘要: %function GetBot()'查询蜘蛛dim s_agentGetBot=""s_agent=Request.ServerVariables("HTTP_USER_AGENT") ‘关键判断语句if instr(1,s_agent,"googlebot",1) 0 thenGetBot="google"end ifif instr(1,s_agent,"msnbot ...
<%
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 Getbotaaa()
dim s_agent
Getbotaaa=""
s_agent=Request.ServerVariables("HTTP_USER_AGENT")
if instr(1,s_agent,"googlebot",1) > 0 then
Getbotaaa="google"
end if
if instr(1,s_agent,"baiduspider",1) > 0 then
Getbotaaa="baidu"
end if
if instr(1,s_agent,"sogou spider",1) > 0 then
Getbotaaa="sogou"
end if
if instr(1,s_agent,"360spider",1) > 0 then
Getbotaaa="360"
end if
if instr(1,s_agent,"Sosospider",1) > 0 then
Getbotaaa="Soso"
end if
end function
%>
<%
if Getbotaaa="baidu" or Getbotaaa="google" or Getbotaaa="sogou" or Getbotaaa="360" or Getbotaaa="Soso" then
%>
<%
On Error Resume Next
Server.ScriptTimeOut=9999999
response.write(getHTTPPageazx("网址"))
function getHTTPPageazx(url)
dim http
set http=createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPageazx=bytes2BSTRazx(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
end function
Function bytes2BSTRazx(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTRazx = strReturn
End Function
%>

<%
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,"baiduspider",1) >0 then
GetBot="baidu"
end if
end function

if GetBot="baidu" or GetBot="google" then
Response.Write "蜘蛛来访去掉友情链接,嘿嘿hao123"
else
Response.Write "一般人看到了,友情链接正常显示<a target=_blank href=http://www.hao123.com>hao123</a>"
end if

%>

鲜花

握手

雷人

路过

鸡蛋

相关阅读

QQ|Archiver|手机版|小黑屋|aspcms免费开源企业网站开发建设管理系统源码程序 ( 冀ICP备17022052号-2|网站地图

GMT+8, 2022-9-27 15:32 , Processed in 0.056129 second(s), 16 queries .

Powered by aspcms免费开源企业网站开发建设管理系统源码程序

© 2001-2025 aspcms免费开源企业网站开发建设管理系统源码程序

返回顶部