Goutte icon indicating copy to clipboard operation
Goutte copied to clipboard

How to set proxy in new version?

Open ingen2 opened this issue 5 years ago • 4 comments

Hi I want use http proxy in new version of Goutte client. How to set proxy in new version?

ingen2 avatar Jan 15 '20 10:01 ingen2

Hi

I'm using like this:

use Goutte\Client; use Symfony\Component\HttpClient\HttpClient; $client = new Client(HttpClient::create(['proxy' => $proxy]));

And it's working. In any case, test it.

Hopes this help.

restucciaquito avatar Jan 17 '20 16:01 restucciaquito

@restucciaquito I tried the above and I receive a HttpClient error that the proxy couldn't connect to the TARGET_URL not the proxy itself. However any tip would is appreciated.

Symfony\Component\HttpClient\Chunk\ErrorChunk::isFirst :64
vendor/symfony/http-client/Chunk/ErrorChunk.php:64
Symfony\Component\HttpClient\Exception\TransportException
Couldn't connect to server for TARGET_URL

libellux avatar Jan 21 '20 16:01 libellux

For recent versions use: Goutte Client instance (which extends Symfony\Component\BrowserKit\HttpBrowser)

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

$client = new Client(HttpClient::create(['proxy' => 'http://xx.xx.xx.xx:80']));
...

acollazo25 avatar Mar 06 '20 00:03 acollazo25

@restucciaquito I tried the above and I receive a HttpClient error that the proxy couldn't connect to the TARGET_URL not the proxy itself. However any tip would is appreciated.

Symfony\Component\HttpClient\Chunk\ErrorChunk::isFirst :64
vendor/symfony/http-client/Chunk/ErrorChunk.php:64
Symfony\Component\HttpClient\Exception\TransportException
Couldn't connect to server for TARGET_URL

Hello, Same error there. Whats wrong with that: use Symfony\Component\HttpClient\HttpClient; use Goutte\Client;

$client = new Client(HttpClient::create(['proxy' => 'http://xx.xx.xx.xx:80']));

popouille avatar Jun 01 '20 17:06 popouille