FriendsOfPHP / Goutte

Goutte, a simple PHP Web Scraper
MIT License
9.26k stars 1.01k forks source link

Setting curl options #404

Closed jmichaelterenin closed 4 years ago

jmichaelterenin commented 4 years ago

I'm using the latest version of Goutte, and cannot find the latest information on how to set CURL options. All I keep finding is older threads that no longer work.

It's clear that I need to make use of this:

use Goutte\Client;
use Symfony\Component\HttpClient\HttpClient;

$client = new Client(HttpClient::create(['timeout' => 60]));

Not sure if I should be using CurlHttpClient or HttpClient will do.

Specifically, I'm needing to set the following curl options: CURLOPT_FOLLOWLOCATION, CURLOPT_RETURNTRANSFER, CURLOPT_FORBID_REUSE, CURLOPT_HTTPPROXYTUNNEL, CURLOPT_FRESH_CONNECT, CURLOPT_SSL_VERIFYPEER

Please help! Thank you

jmichaelterenin commented 4 years ago

UPDATE: so I know now that I can use HttpClient, from the following documentation tidbit:

HttpClient::create() selects the cURL transport if the cURL PHP extension is enabled and falls back to PHP streams otherwise.

Still looking for how to set the specific curl options ...

jmichaelterenin commented 4 years ago

I Was able to get the response to my query through the Slack Symphony Dev group.

iaK commented 4 years ago

... and the answer was?

jmichaelterenin commented 4 years ago

mostly stuff from this page: https://symfony.com/doc/current/reference/configuration/framework.html#reference-http-client