|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
A high performance database engine using optimized data access for all development environments including Delphi, Visual Studio .NET, Visual Basic, Visual FoxPro. and more. Learn More |
|
#1
|
|||
|
|||
|
This is my way to detect search engine bots quickly with C#. do u think is accurate?
I was looking for a way of finding good search bots without going through huge list of User-agents.
This is the code I came up with: string userAgent = HttpContext.Current.Request.UserAgent.ToLower(); string[] botKeywords = new string[10]{ "bot", "spider", "google", "yahoo", "search", "crawl", "slurp", "msn", "teoma", "ask.com" }; int n = 0; foreach (string bot in botKeywords) { if (userAgent.Contains(bot)) n++; } bool isBot = (n>1); What do you think? Is it accurate? How can this be improved? Thanks |
|
#2
|
|||
|
|||
|
Sorry I didn't explain the code for who doesn't know C#.
In practise if the User-agent contains any 2 or more keywords from this list ("bot", "spider", "google", "yahoo", "search", "crawl", "slurp", "msn", "teoma", "ask.com") than it's considered a bot and probably a search bot. I did this to have a way to find bots and make this durable also in the future without having to update any list. |
![]() |
| Viewing: SEO Chat Forums > Search Engine Strategies > Search Engine Spiders > This is my way to detect search engine bots quickly with C#. do u think is accurate? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|