Detect crawlers and bots with CrawlerDetect
masterCrawlerDetect is a PHP library that identifies bots, crawlers, and spiders by analyzing the User-Agent and HTTP_FROM headers. You can use it to check the current visitor's user agent or pass a specific string for inspection.
use Jaybizzle\\\CrawlerDetect\\\CrawlerDetect;
$CrawlerDetect = new CrawlerDetect;
// Check the user agent of the current visitor
if ($CrawlerDetect->isCrawler()) {
// true if a crawler user agent was detected
}
// Pass a user agent as a string
if ($CrawlerDetect->isCrawler('Mozilla/5.0 (compatible; Sosospider/2.0; +http://help.soso.com/webspider.htm')) {
// true if a crawler user agent was detected
}
// Output the name of the bot that matched (if any)
echo $CrawlerDetect->getMatches();