rookie0 / real-useragent
v0.1
2019-02-02 03:08 UTC
Requires
- cache/array-adapter: ^1.0
- guzzlehttp/guzzle: ^6.3
- psr/simple-cache: ^1.0
- symfony/dom-crawler: ^3.4|^4.2
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2025-03-21 21:38:58 UTC
README
Up to date useragent faker with real world database(grab from WhatIsMyBrowser.com).
Installation
composer require rookie0/real-useragent
Usage
Basic usage
use Rookie0\RealUserAgent\UserAgent; // optional $config = [ 'timeout' => 5, // grab request timeout 'cache_ttl' => 60 * 60, // cache grab content expired time 'cache_key_prefix' => 'realuseragent', 'page_num' => 3, // grab content page num ]; // optional default array cache $cache = instance of Psr\SimpleCache\CacheInterface; $ua = new UserAgent($config, $cache); // get fake useragent by accessing properties echo $ua->chrome; // filter by call methods echo $ua->firefox(); echo $ua->wechat, PHP_EOL, $us->ucBrowser;
Or filter a useragent by yourself, check needed info from WhatIsMyBrowser.com.
- Software Names
- Operating Systems
- Operating Platforms
- Software Types
- Hardware Types
- Layout Engine Names
// optional $filter = [ 'category' => 'software_name', 'name' => 'chrome', 'order_by' => '-times_seen', 'software_version' => '', 'operating_system' => '', 'hardware_type' => '', ]; // refresh cache optional defalut false $refresh = true; echo $ua->random($filter, $refresh); // grab useragents content // software_name operating_system_name operating_platform software_type_specific hardware_type_specific layout_engine_name $category = 'operating_system_name'; $name = 'linux'; // - for desc $orderBy = 'software_type_specific'; var_dump($ua->collect($category, $name, $orderBy, $refresh));