jaybizzle/crawler-detect
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Jaybizzle/Crawler-detect is an efficient PHP library designed to detect bots, crawlers, and spiders by analyzing the 'user agent' and 'http_from' header. Currently, the library has the capability to discern thousands of bots, crawlers, and spiders making it a valuable tool for web analytics, SEO improvements, and security.
To utilize the jaybizzle/crawler-detect, you need to install it first with composer by running the command: composer require jaybizzle/crawler-detect
. After that, you can implement it with the following PHP code:
use Jaybizzle\CrawlerDetect\CrawlerDetect;
$CrawlerDetect = new CrawlerDetect;
// Check the user agent of the current 'visitor'
if($CrawlerDetect->isCrawler()) {
// true if crawler user agent 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 crawler user agent detected
}
// Output the name of the bot that matched (if any)
echo $CrawlerDetect->getMatches();
This example demonstrates checking if the current visitor's user agent is a crawler and if a given user agent string is a crawler. Additionally, it shows how to output the name of the detected bot.
The documentation for jaybizzle/crawler-detect is mainly found within the README file in the GitHub repository. Additionally, further information and insights about the package can be found at crawlerdetect.io.