commencement.technology / botcheck
该包用于识别机器人或爬虫,有助于识别每天访问的机器人或爬虫数量及其来源
1.0.1
2022-09-11 10:40 UTC
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2024-09-11 15:31:33 UTC
README
Bot check 解析用户代理并返回有关机器人、爬虫、浏览器和操作系统信息的有用细节。目标是在机器人、爬虫、最常用的设备、浏览器、硬件等方面提供全面的信息。
* Operating System `os` * e.g. Windows, macOS, Linux * Browser `browser` * e.g. Firefox, Safari, Firefox iOS * Hardware `hardware` * e.g. Nintendo Switch, Apple iPad * Miscellaneous `misc` * e.g. Slack, WhatsApp, Gmail, cURL, Python-urllib * Bot `bot` * e.g. Googlebot, BingBot, Baidu Spider
机器人结果数据
* Name * Website * Bot Site Complete page
结果数据概述
* Name * Version * Brand (hardware only) * Model (hardware only) * Mobile (boolean, can be inaccurate)
安装/配置
Packagist commencement.technology/botcheck
$ composer require commencement.technology/botcheck
用法
use CommencementTechnology\Botcheck\BotChecker; // $ua = $request->get('ua'); // OR // $ua = $_SERVER['HTTP_USER_AGENT']; $ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0'; $user_agent = new BotChecker($ua); // If you want all data in that case just use parse $user_agent_info = $user_agent->parse();
结果
[ 'os' => [ 'name' => 'Windows', 'icon' => 'win10', 'version' => '10' ], 'browser' => [ 'name' => 'Firefox', 'icon' => 'firefox', 'version' => '86.0' ], 'hardware' => false, 'misc' => false, 'bot' => false ];
// When you want only Operating system specific details pass as $user_agent_os = $user_agent->parse('os');
结果
[ 'name' => 'Windows', 'icon' => 'win10', 'version' => '10' ];
// When you want only bot or crawler specific details pass as $user_agent_os = $user_agent->parse('bot');
结果
[ 'name' => 'SEMRush Crawler', 'website' => 'http://www.semrush.com', 'complete_link' => 'http://www.semrush.com/bot.html' ];