php - 如何使用 symfony/panther 设置代理服务器

标签 php web-scraping proxy symfony-panther

我发现有两种设置代理服务器的方法,一种是通过 chrome web 驱动程序功能,另一种是在创建 chrome 客户端时直接设置

$this->client = Client::createChromeClient(null, [
            '--proxy-server=socks://196.14.52.63:35048',
            '--headless',
            "--disable-gpu",
]);
但在设置代理 IP 和端口后,我收到以下错误:
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 获取数据。

最佳答案

我通过传递以下配置使其工作。

$this->client = Client::createChromeClient(null, [
            '--window-size=1200,1100',
            "--proxy-server=http://ip:port",
            '--headless',
            "--disable-gpu",
]);

我认为我以前使用的代理服务器不支持 https(我试图访问 https 页面)并且我也缺少 windows-size 参数。

关于php - 如何使用 symfony/panther 设置代理服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59583732/

相关文章:

caching - NGINX try_files 具有多个命名位置

javascript - Nodejs http 代理服务器在 socket.io 连接上崩溃

php - 如果小数点前面有零,则将其删除 - PHP

python - 为什么我会收到 ElementClickInterceptedException 错误?

python - 使用 selenium python 复制文本区域

java - 如何让 Spring Security 在跨多个域的负载均衡器后面工作?

macos - OSX Apache 使用错误版本的 PHP

php - 在 PHP 中计算数组的中位数

javascript - 如何在注销前引发确认警报

python 3 : using requests does not get the full content of a web page