爬虫/机器人如何工作?区分机器人/抓取工具http请求

时间:2015-08-23 11:19:21

标签: c# asp.net seo search-engine google-search

我正在一个网站上工作。

我需要了解我的网站是否可以访问Google或任何其他搜索引擎crawlers/bots

在我的应用程序中,我正在拦截http请求。并且需要找出抓取工具/漫游器是否正在制作http请求来抓取我的网站。

我该怎么做?

1 个答案:

答案 0 :(得分:2)

检查用户代理字符串以查看它是否是已知的机器人。一个例子:

protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.UserAgent.Contains("Googlebot"))
            {
                //it's one of the google robots
            }
            else if (...)
            {
                ...
            }
        }

对于Google,可以在此处找到他们使用的代理商列表here

其他人,你必须找出自己。