Saw a PHP equivelent a few posts back and adapted it for ASP, hope people find it useful.
<%
if session("svBot") <> true then
'################################################# #########################
' Version 1.0
' Code should email users when a bot is crawling through a site
' Code tested on IIS 5 only with CDONTS
' Normally stick the code in an include file and then call on home page of web site
' Should execute only first time BOT is found as session is set. Appears to work ok
' Assume that sessions can be used by BOTs!
' Any suggestions and improvements to my rough and ready code gratefully received
' Tim Howes -
thowes@ssi-ltd.com - 05/04/2003
'################################################# #########################
' Dim varaibles to be used
varUAGENT = Request.ServerVariables("HTTP_USER_AGENT")
varREFERER = Request.ServerVariables("HTTP_REFERER")
varADDR = left(Request.ServerVariables("Remote_ADDR"), 2)
varIAM = ""
' Search for those BOTS
If instr(varUAGENT,"google") OR instr(varUAGENT,"URL_Spider_SQL") OR instr(varUAGENT,"Firefly") OR instr(varUAGENT,"NationalDirectory") OR instr(varUAGENT,"Ask Jeeves") OR instr(varUAGENT,"TECNOSEEK") OR instr(varUAGENT,"InfoSeek") OR instr(varUAGENT,"WebFindBot") OR instr(varUAGENT,"girafabot") OR instr(varUAGENT,"crawler") OR instr(varUAGENT,"www.galaxy.com") OR instr(varUAGENT,"Googlebot") OR instr(varUAGENT,"Scooter") OR instr(varUAGENT,"Slurp") OR instr(varUAGENT,"appie") OR instr(varUAGENT,"FAST") OR instr(varUAGENT,"fast") OR instr(varUAGENT,"WebBug") OR instr(varUAGENT,"Spade") OR instr(varUAGENT,"ZyBorg") OR instr(varUAGENT,"rabaz") Then
' Determine the google bot
if varADDR = 21 AND instr(varUAGENT,"google") Then
varIAM = "Googlebot"
end if
if varADDR = 64 AND instr(varUAGENT,"google") Then
varIAM = "Freshbot"
end if
' String the info message together
if varREFERER <> "" then
strMessage = "Refer:" & varREFERER & VbCrlf
end if
if varUAGENT <> "" then
strMessage = strMessage & "Agent:" & varUAGENT & VbCrlf
end if
if varIAM <> "" then
strMessage = strMessage & " I am:" & varIAM & VbCrlf
end if
' Send that email
Set usxCDO = Server.CreateObject("CDONTS.NewMail")
usxCDO.From = "bot@yourwebsite.com"
usxCDO.To = "fred@yourwebsite.com"
usxCDO.CC = "wendy@yourwebsite.com"
usxCDO.BCC = "humperdink@yourwebsite.com"
usxCDO.Subject = "A Spider Is Crawling!!!"
usxCDO.Body = strMessage
usxCDO.Send
Set usxCDO = Nothing
End If
' Set session to stop it sending email again and again
session("svBot") = true
End If
%>
Sorry if indentation is missing.....
-------(())------
<mod edit>