Skip to content

Instantly share code, notes, and snippets.

@Jalalx
Created October 24, 2016 13:00
Show Gist options
  • Save Jalalx/887fdce314f5e29b6dc034621820b6c3 to your computer and use it in GitHub Desktop.
Save Jalalx/887fdce314f5e29b6dc034621820b6c3 to your computer and use it in GitHub Desktop.
Detects most know crowlers
public class BotUserAgentUtility
{
public static bool IsBot(string userAgent)
{
var Crawlers = new List<string>()
{
"googlebot","bingbot","yandexbot","ahrefsbot","msnbot","linkedinbot","exabot","compspybot",
"yesupbot","paperlibot","tweetmemebot","semrushbot","gigabot","voilabot","adsbot-google",
"botlink","alkalinebot","araybot","undrip bot","borg-bot","boxseabot","yodaobot","admedia bot",
"ezooms.bot","confuzzledbot","coolbot","internet cruiser robot","yolinkbot","diibot","musobot",
"dragonbot","elfinbot","wikiobot","twitterbot","contextad bot","hambot","iajabot","news bot",
"irobot","socialradarbot","ko_yappo_robot","skimbot","psbot","rixbot","seznambot","careerbot",
"simbot","solbot","mail.ru_bot","spiderbot","blekkobot","bitlybot","techbot","void-bot",
"vwbot_k","diffbot","friendfeedbot","archive.org_bot","woriobot","crystalsemanticsbot","wepbot",
"spbot","tweetedtimes bot","mj12bot","who.is bot","psbot","robot","jbot","bbot","bot"
};
// HttpContext.Current.Request.UserAgent.ToLower();
userAgent = userAgent.ToLower();
var iscrawler = Crawlers.Exists(x => userAgent.Contains(x));
return iscrawler;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment