如何使用symfony/panther设置代理服务器
问题描述:
我发现设置代理服务器的两种方法之一是通过chrome Web驱动程序功能,另一种是在创建chrome客户端时直接设置
I found two way of setting proxy server one is through chrome web driver capabilities and the other one is directly setting while creating chrome client
$this->client = Client::createChromeClient(null, [
'--proxy-server=socks://196.14.52.63:35048',
'--headless',
"--disable-gpu",
]);
但是在设置代理IP和端口后,出现以下错误:
but after setting proxy IP and port I get following error:
Curl error thrown for http POST to /session/cce06908d68a1e96bc6d1cb3b798aa14/url with params: {"url":"https:\/\/some-site\/login"}\n
Operation timed out after 30001 milliseconds with 0 bytes received
基本上,我想在使用Symfony panther抓取数据时使用代理服务器.
Basically I want to use proxy servers while scrapping data using Symfony panther.
答
我通过以下配置使其起作用.
i made it work with passing following configuration.
$this->client = Client::createChromeClient(null, [
'--window-size=1200,1100',
"--proxy-server=http://ip:port",
'--headless',
"--disable-gpu",
]);
我认为以前使用的代理服务器不支持https(我曾尝试访问https页面),而且我也缺少windows-size参数.
i think previously proxy server i was using doesn't support https (i was try to visit https page) and i was also missing windows-size argument.