asp.net (C #) capture search engine Spider and robot _ practical skills

Source: Internet
Author: User
The following is an access log file
2008-8-13 14:43:22

mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1. NET CLR 2.0.50727;. NET CLR 1.1.4322)



2008-8-13 14:43:27

mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1. NET CLR 2.0.50727;. NET CLR 1.1.4322)



2008-8-13 14:44:18

mozilla/5.0 (compatible; Yahoo! Slurp; HTTP://HELP.YAHOO.COM/HELP/US/YSEARCH/SLURP)



2008-8-13 14:44:26

mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; Qqdownload 1.7;. NET CLR 1.1.4322;. NET CLR 2.0.50727;. NET CLR 3.0.04506.648;. NET CLR 3.5.21022)



2008-8-13 14:45:17

mozilla/5.0 (compatible; Yahoo! Slurp; HTTP://HELP.YAHOO.COM/HELP/US/YSEARCH/SLURP)

Open this file, this file is used to record access to the search bar of the normal visitors or robot spiders, extracted from the Spider: mozilla/5.0 (compatible; googlebot/2.1; +http://www.google.com/bot.html)

gigabot/3.0 (http://www.gigablast.com/spider.html)

mozilla/5.0 (compatible; Yahoo! Slurp; HTTP://HELP.YAHOO.COM/HELP/US/YSEARCH/SLURP)

mozilla/5.0 (compatible; yodaobot/1.0; http://www.yodao.com/help/webmaster/spider/; )

Sogou Web spider/4.0 (+http://www.sogou.com/docs/help/webmasters.htm#07)

msnbot/1.1 (+http://search.msn.com/msnbot.htm)

baiduspider+ (+http://www.baidu.com/search/spider.htm)

The code is also very simple:
Copy Code code as follows:

String agent = system.web.httpcontext.current.request.servervariables["Http_user_agent"];
if (Agent = = null)
{
Response.Write ("other");
}
Else
{
Response.Write (agent);
}

You can try this code yourself and find out that it will output something like this: mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Tencenttraveler 4.0;. NET CLR 2.0.50727;. NET CLR 1.1.4322)
Combining this you can write a spider access record, how to judge a normal user or spider? This can be roughly judged: by judging the user's Access source page, such as from the jb51.net/index.htm file point into show.asp?id=11 then his source page we know is jb51.net/index.htm, then rough judgment he is a normal customer. And the source of spiders is not, this part is not recorded down, and then choose from. Can be recorded in conjunction with the database.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.