【问题标题】:How can i set proxy server with symfony/panther如何使用 symfony/panther 设置代理服务器
【发布时间】:2020-01-03 18:44:08
【问题描述】:

我发现了两种设置代理服务器的方法,一种是通过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 抓取数据时使用代理服务器。

【问题讨论】:

  • 您是否确定您的代理可以使用此配置,例如通过在浏览器中配置并手动尝试?

标签: php web-scraping proxy symfony-panther


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 2014-03-30
    • 2017-05-21
    相关资源
    最近更新 更多