Setting CURL Parameters for fabpot/goutte Client

限于喜欢 提交于 2019-12-05 12:55:58

To set curl options by the way, it looks like guzzle recognizes the key "curl" as a config setting, which takes in an array of curl-related config values. So the equivalent of what you were initially trying to achieve would look like the following

$client = new \Goutte\Client();

$guzzleClient = new \GuzzleHttp\Client(array(
    'curl' => array(
        CURLOPT_TIMEOUT => 60,
    ),
));
$client->setClient($guzzleClient);
$crawler = $client->request('GET', $my_url);

Not sure how well this is supported since it isn't indicated anywhere in the guzzle docs (and doing it this way makes it look like its dependent on CURL, which I think is not the intention of guzzle. Hence the general timeout config entry).

What I ended up doing is the following:

$this->client->setClient(new GuzzleClient(['verify' => false]));

The 'verify' => false when initiating the GuzzleClient makes it not verify the certificates.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!