1. Go to this page and download the library: Download larva/agent 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/ */
$agent->setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15');
// 或者一次性注入完整的 HTTP 头(会自动从中提取 User-Agent)
$agent->setHttpHeaders($headers);
$agent = new Agent(config: ['autoInitOfHttpHeaders' => false]);
$agent->setUserAgent($userAgent);