1. Go to this page and download the library: Download vipnytt/useragentparser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vipnytt / useragentparser example snippets
use vipnytt\UserAgentParser;
$parser = new UserAgentParser('googlebot/2.1');
$product = $parser->getProduct()); // googlebot
use vipnytt\UserAgentParser;
$parser = new UserAgentParser('googlebot-news/2.1');
$userAgents = $parser->getUserAgents());
array(
'googlebot-news/2.1',
'googlebot-news/2',
'googlebot-news',
'googlebotnews',
'googlebot'
);
use vipnytt\UserAgentParser;
$parser = new UserAgentParser('googlebot-news');
$match = $parser->getMostSpecific(['googlebot/2.1', 'googlebot-images', 'googlebot'])); // googlebot
$parser = new UserAgentParser('MyCustomCrawler/1.2');
// Determine the correct rule set (robots.txt / robots meta tag / x-robots-tag)
$parser->getMostSpecific($array); // string
// Parse
$parser->getUserAgent(); // string 'MyCustomCrawler/1.2'
$parser->getProduct(); // string 'MyCustomCrawler'
$parser->getVersion(); // string '1.2'
// Crunch the data into groups, from most to less specific
$parser->getUserAgents(); // array
$parser->getProducts(); // array
$parser->getVersions(); // array
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.