次のコードは、検索エンジンに適切なコンテンツを表示することを目的としていますが、これは SEO にとって良くないことに注意してください。お勧めしません。学習の参考として。
次のコードをコピーします。<%
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 instr(1,s_agent,baiduspider,1) >0 then
GetBot=baidu
end if
instr(1,s_agent,sohu-search,1) >0 then
GetBot=Sohu
end 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
'Baidu 用にカスタマイズされたコンテンツ
elseif GetBot=google then
'Google 用にカスタマイズされたコンテンツ
end if
%>
以下はより完全ですコードが必要な方も参照してください。一部の顧客情報も含まれます。
次のようにコードをコピーします。
Class SystemInfo_Cls
Public Browser、バージョン、プラットフォーム、IsSearch、AlexaToolbar
Private Sub Class_Initialize()
Dim Agent、Tmpstr
IsSearch = False
If Not IsEmpty(Session(SystemInfo_Cls)) then
Tmpstr = Split(Session(SystemInfo_Cls), | | |)
ブラウザ = Tmpstr(0)
バージョン = Tmpstr(1)
プラットフォーム = Tmpstr(2)
AlexaToolbar = Tmpstr(4)
If Tmpstr(3) = 1 then
IsSearch = True
End If
Exit Sub
End If
Browser = 不明な
バージョン = 不明な
プラットフォーム = 不明
Agent = Request.ServerVariables(HTTP_USER_AGENT)
If InStr(Agent, Alexa)ツールバー) > 0 then
AlexaToolbar = YES
Else
AlexaToolbar = NO
End If
Left(Agent, 7) = Mozilla then 'ブラウザにはこの識別子があります
Agent = Split(Agent, ;)
If InStr(Agent(1), MSIE) > 0 then
Browser = Internet Explorer
version = Trim(Left(Replace(Agent(1), MSIE, ) , 6))
ElseIf InStr(Agent(4), Netscape) > 0 then
Browser = Netscape
Tmpstr = Split(Agent(4), /)
version = Tmpstr(UBound(Tmpstr))
ElseIf InStr(Agent(4), rv:) > 0 then
Browser = Mozilla
Tmpstr = Split(Agent(4), :)
version = Tmpstr(UBound(Tmpstr))
If InStr(version, ) ) > 0 then
Tmpstr = Split(version, ))
version = Tmpstr(0)
End If
End If
If InStr(Agent(2), NT 5.2) > 0
プラットフォーム = Windows 2003
ElseIf InStr(Agent(2), Windows CE) > 0
プラットフォーム = Windows CE
ElseIf InStr(Agent(2), NT 5.1) > 0
プラットフォーム = Windows XP
ElseIf InStr(Agent( 2)、NT 4.0) > 0
プラットフォーム = Windows NT
ElseIf InStr(Agent(2), NT 5.0) > 0プラットフォーム
= Windows 2000
ElseIf InStr(Agent(2), NT) > 0
プラットフォーム = Windows NT
ElseIf InStr(Agent(2), 9x) > 0
プラットフォーム = Windows ME
ElseIf InStr(Agent(2), 98) > 0 の場合、
プラットフォーム = Windows 98
ElseIf InStr(Agent(2), 95) > 0 の場合、
プラットフォーム = Windows 95
ElseIf InStr(Agent(2), Win32) > 0
プラットフォーム = Win32
ElseIf InStr(Agent(2), Linux) > 0
プラットフォーム = Linux
ElseIf InStr(Agent(2), SunOS) > 0
プラットフォーム = SunOS
ElseIf InStr( Agent(2), Mac) > 0 then
platform = Mac
ElseIf UBound(Agent) > 2 then
If InStr(Agent(3), NT 5.1) > 0 の場合、
プラットフォーム = Windows XP
End
If InStr(Agent(3), Linux) > 0 の場合、
プラットフォーム = Linux
End If
End If
If InStr(Agent(2), Windows) > 0 かつ、プラットフォーム = 不明の場合、
プラットフォーム = Windows
End If
ElseIf Left(Agent, 5) = Opera then 'ブラウザにはこの識別子があります
Agent = Split(Agent, /)
Browser = Mozilla
Tmpstr = Split(Agent(1), )
version = Tmpstr(0)
If InStr(Agent(1), NT 5.2) > 0 then
platform = Windows 2003
ElseIf InStr(Agent(1), Windows CE) > 0 then
platform = Windows CE
ElseIf InStr(Agent(1), NT 5.1 ) > 0
プラットフォーム = Windows XP
ElseIf InStr(Agent(1), NT 4.0) > 0
プラットフォーム = Windows NT
ElseIf InStr(Agent(1), NT 5.0) > 0
プラットフォーム = Windows 2000
ElseIf InStr(Agent(1), NT) > 0
プラットフォーム = Windows NT
ElseIf InStr(Agent(1), 9x) > 0
プラットフォーム = Windows ME
ElseIf InStr(Agent(1), 98) > 0
プラットフォーム = Windows 98
ElseIf InStr(Agent(1), 95) > 0
プラットフォーム = Windows 95
ElseIf InStr(Agent(1), Win32) > 0
プラットフォーム = Win32
ElseIf InStr(Agent(1), Linux) > 0
プラットフォーム = Linux
ElseIf InStr(Agent(1), SunOS) > 0 の場合、
プラットフォーム = SunOS
ElseIf InStr(Agent(1), Mac) > 0 の場合、
プラットフォーム = Mac
ElseIf UBound(Agent) > 2 の
場合InStr(Agent(3), NT 5.1) > 0 then
platform = Windows XP
End If
If InStr(Agent(3), Linux) > 0 then
platform = Linux
End If
End If
Else
'検索エンジンを識別
Dim botlist, i
botlist = Google、Isaac、Webdup、SurveyBot、Baiduspider、ia_archiver、P.Arthur、FAST-WebCrawler、Java、Microsoft-ATL-Native、TurnitinBot、WebGather、Sleipnir
botlist = Split(botlist, ,)
For i = 0 To UBound(botlist)
InStr(Agent, botlist(i)) > 0 の場合、
プラットフォーム = botlist(i) & SearcherIsSearch
= True
End
If
Next
End If
IsSearch then
Browser =
version =
Session(SystemInfo_Cls) = ブラウザ & ||| & バージョン & ||| & AlexaToolbar
Else
Session (SystemInfo_Cls) ) = ブラウザ & ||| & バージョン & ||| & プラットフォーム & |||0|||
End If
End Sub
End Class