怎样才能判断是否搜索引擎呢?

<%
'检查当前用户是否是蜘蛛人
Function check(user_agent)
    allow_agent=split("Baiduspider,Scooter,ia_archiver,Googlebot,FAST-WebCrawler,MSNBOT,Slurp",",")
    check_agent=false
    For agenti=lbound(allow_agent) to ubound(allow_agent)
        If instr(user_agent,allow_agent(agenti))>0 then
            check_agent=true
            exit for
        end if
    Next
    check=check_agent
End function
user_agent=Request.ServerVariables("HTTP_USER_AGENT")
'check(user_agent)=true则判定访问为蜘蛛人
%>

上面的代码没有测试过,去试试...不知道行不行...

 

 

<%
Sub robot()
        Dim robots:robots="Baiduspider+@Baidu|Googlebot@Google|ia_archiver@Alexa|IAArchiver@Alexa|ASPSeek@ASPSeek|YahooSeeker@Yahoo|SogouBot@sogou|help.yahoo.com/help/us/ysearch/slurp@Yahoo|sohu-search@SOHU|MSNBOT@MSN"
        dim I1,I2,l1,l2,l3,i,rs
        l2=false
        l1=request.servervariables("http_user_agent")
        F1=request.ServerVariables("SCRIPT_NAME")
        I1=split(robots,chr(124))
        for i=0 to ubound(I1)
                I2=split(I1(i),"@")
                if instr(lcase(l1),lcase(I2(0)))>0 then
                        l2=true:l3=I2(1):exit for
                end if
        next
        if l2 and len(l3)>0 then'如果是爬虫,就更新爬虫信息
                FilePath = Server.Mappath("robots/"&l3&"_robots.txt")
                '记录蜘蛛爬行
                Set Fso = Server.CreateObject("Scripting.FileSystemObject")
                Set Fout = Fso.OpenTextFile(FilePath,8,True)
                                Fout.WriteLine "索引页面:"&F1
                                Fout.WriteLine "蜘蛛:"&l3&chr(32)&chr(32)&"更新时间:"&Now()
                                Fout.WriteLine "-----------------------------------------------"
                                Fout.Close
                Set Fout = Nothing
                Set Fso = Nothing
        end if
end Sub
%>

先在你的站里建立一个robots文件夹,把robots.asp放到robots文件夹下,再把调用函数放在公用的函数文件里面。因为一般网站都会用到数据库,所以只要Call robot()写进去就行了。
下面给一个参考,是我的小站的数据库文件:

<!--#include file="robots/robots.asp"-->
<%
Set Conn=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="+server.mappath("data/gata.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"
Conn.Open connstr

Call robot()

%>

还有一点要说明:蜘蛛爬了你的站,但不一定会收录

转载于:https://www.cnblogs.com/tecsoon/archive/2009/06/25/1511057.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值