Allow to override Curl options passed to Guzzle request #69
Comments
You can add custom curl options to clients when injecting a Guzzle client into a Goutte client. If you prefix a client configuration option name with See http://guzzlephp.org/tour/http.html#low-level-curl-access |
@mtdowling - Thanks. It works :) |
Note: This is no longer the correct answer for redirects (and is seemingly unreliable now), there is now |
Unfortunately both of these links are no longer valid. |
It's not there any more, can you find the correct link? tkx. |
I think this is it - http://guzzle.readthedocs.org/en/latest/clients.html#config |
If you are using a recent release of $client = new \Goutte\Client();
$client->getClient()->setDefaultOption('config', ['curl' => ['CURLOPT_TIMEOUT' => 60]]);
$crawler = $client->request('GET', $url); |
I was trying to use codeception to test my api call which can take a long time and I wanted to put the timeout to 0.
I got most of this from somewhere else though. |
For Goutte 1 / Guzzle 3 / PHP 5.3: $client->getClient()->getConfig()->set('curl.options', array(CURLOPT_TIMEOUT => 30)); |
@ssanders Could you add a note in the README file? |
That's not how it works in Guzzle 4. See: http://docs.guzzlephp.org/en/latest/faq.html#how-can-i-add-custom-curl-options and http://docs.guzzlephp.org/en/latest/clients.html#creating-a-client. This could be set after a client is created using: $client->getClient()->setDefaultOption('config/curl/' . CURLOPT_XYZ, 'Foo'); There is no need to set things like timeout as that can be handled by Guzzle for various adapters using request options: http://docs.guzzlephp.org/en/latest/clients.html#timeout |
I don’t think that actually works in Goutte 2. I set Guzzle itself, which I think has no default timeout, works OK, no options changed. |
Modify your scrapping url. It works for me. Hope it helps you. |
Currently curl options are hardcoded in
Client.php
, but sometimes more options have to be set (increase timeout or max. redirects).Code from
Client.php
:The text was updated successfully, but these errors were encountered: