-
Notifications
You must be signed in to change notification settings - Fork 0
berry.utils.CrawlerDetector
Nikos Siatras edited this page Oct 1, 2022
·
7 revisions
CrawlerDetector class implements methods to detect crawlers and bots, such as Googlebot, Bingbot, Ahrefsbot and others, visiting the website.
public function getCrawlerName():string
If the current client is a crawler then this method returns the crawler's name. Otherwise it returns "" (String empty)
The following example initializes a CrawlerDetector object and checks if the current client visiting the website is a crawler.
require_once(__DIR__ . "/berry/utils.php"); // Include berry utils package
$crawlerDetector = new CrawlerDetector();
$crawlerName = $crawlerDetector->getCrawlerName();
if ($crawlerName != "")
{
print "Crawler Detected: " . $crawlerName;
}