If the target website determines your browser type by examining the User-Agent header, you can try modifying the User-Agent header to simulate access from another browser, thereby bypassing the website's detection mechanism. In PHP, you can use the cURL library to send HTTP requests and set the User-Agent header.
Here is an example code:
// 设置目标 URL
$url = 'https://example.com';
// 初始化 cURL
$ch = curl_init();
// 设置 cURL 选项
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 设置 User-Agent 头信息
$user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36';
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
// 发送 HTTP 请求
$response = curl_exec($ch);
// 关闭 cURL
curl_close($ch);
// 处理响应结果
if ($response === false) {
echo '请求失败';
} else {
echo $response;
}In the above code, we use the Chrome browser's User-Agent header to simulate a browser visit. You can also select the User-Agent header for other browsers depending on your specific requirements.