一、环境:
php7.4、centos7.8
二、安装
1、安装symfony/panther包:
composer require symfony/panther
2、安装chrome相关软件
yum install chromium yum install chromedriver #默认安装在 /usr/bin/
3、使用:
// 创建Panther浏览器客户端
$client = Symfony\Component\Panther\Client::createChromeClient($this->chromeDriver, [
'--headless',
"--ignore-certificate-errors",
"--no-sandbox",
"--disable-gpu"
]);
$crawler = $client->request('GET', '要访问的网址');
//其他操作,具体查看官方的使用指南:https://github.com/symfony/panther