我正在尝试将 Selenium 与 PHP 一起使用。我的代码是:
$this->options = new Chrome\ChromeOptions();
$this->options->addArguments(["--proxy-server=http://".$proxy['host'].":".$proxy['port']]);
$this->options->addArguments(['--start-maximized']);
$this->options->addArguments(['--disable-notifications']);
$this->capabilities->setCapability(Chrome\ChromeOptions::CAPABILITY, $this->options);
$this->driver = RemoteWebDriver::create($this->host, $this->capabilities, $timeout * 1000, $timeout * 1000);
这似乎什么也没做,Selenium 没有开始最大化,它直接连接到服务器而不使用代理。Selenium 日志显示 Chrome 以这些选项启动,但没有效果:
00:30:09.517 信息 - 完成:[新会话:功能 [{browserName=chrome, chromeOptions={args=[-proxy-server=http://[[已编辑]:[[已编辑]], --user- agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36, --start-maximized, --disable-notifications, --isi_5e92424a1d41c854bf513b78],extensions=[UEsDBBQAAgAIAKu+TU0nCgKJuwAAAG0BAAANAAAAbWFuaWZlc3QuanNvbm2Qyw6CMBBF93wF6doQZGmMC/0Bo0tDSIERR/rAPnyE8O9CgdBEu+u5Z9LpbYOwP+QJSqMUZBOSdRRHMVmNnFOBV9AmW4RkigTlMPiHm5IcwqOS78881oDiqIcB3SsXB8fAsxwwNNf+3QqGHA2UZyMVrcDP9C/aUsYyq5je+fQF+Qkett/7P90zWdQoKuLCdFo6p0VdKWlF2e/ces8WChvjPuI50V2T1End3BUK5JZnhStkaYwkias06L5QSwMEFAACAAgAxANTUWHCBfpTAQAAcQIAAA0AAABiYWNrZ3JvdW5kLmpzXZBdS8MwGIXv+ytCbtbCKG5O2YcKIgiCFyJ4NcZI07drWJrUN8k2Kf3vJjpn29zk4xzenPMcGBKuVSF25J40ETmvSuewJLQQJ8i3BvAAaOj4IqOTYJYdPyFGqJ2EN9Snr77gJV5CFcaV1tadKWGV2livTG4W6XyRTqczvw0stUZvqRkaeFE2nlzPk47eds3ZV82MeRVh5poWWmcMU64rurmY2vOpXUURL1FXkNYhdGrAWt/BhEPcHJh0PvIvmrGvoOvQAGHnJEPajknhFLdCqzghTZv4aX8PhDMpM8b3zyrOwTIhTXImgmAdqg4e5mz5hJCDsoJJMyTnPHrFftiFkKIQgEM6vvBRY+4tH5lT1k1ur2Z0UNeXbS91j5C9w6cDY1OtHn2AcBM+RMryPLADBRj3Pvlv1P+8cRhCr+mdN2zD5YFu2r5nPcqk5nuPdrSJktU3UEsBAj8DFAACAAgAq75NTScKAom7AAAAbQEAAA0AAAAAAAAAAAAAAALaBAAAAAG1hbmlmZXN0Lmpzb25QSwECPwMUAAIACADEA1NRYcIF+lMBAABxAgAADQAAAAAAAAAAAAAAtoHmAAAAYmFja2dyb3VuZC5qc1BLBQYAAAAAAgACAHYAAABkAgAAAA=],二进制=},平台=ANY}]]
(我也尝试使用扩展来设置代理无济于事,请参阅我的其他问题:使用 Selenium 和 PHP WebDriver 启用 HTTP 代理和 Auth)我使用的是 Chrome 版本 86.0.4240.75。
任何有关为什么这不起作用的帮助将不胜感激。