K
K
Kirill Gorelov2018-11-23 10:13:52
PHP
Kirill Gorelov, 2018-11-23 10:13:52

How to get curl_getinfo from Goutte library?

Hello.
I chose the library for crawling Goutte
But I need to get another array of data from it from curl_getinfo.
Neither Google nor the documentation helped.
But this library uses Guzzle, you can get this array from it, but I don’t know how to call this method in guzzle from Goutte.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eternalfire, 2018-11-23
@Kirill-Gorelov

everything is in the docks

$client = new \Goutte\Client();

$guzzleClient = new \GuzzleHttp\Client(array(
    'curl' => array(
        CURLOPT_TIMEOUT => 60,
    ),
));

$client->setClient($guzzleClient);

$crawler = $client->request('GET', 'http://httpbin.org/stream/1024', [
    'on_stats' => function (TransferStats $stats) {
        echo $stats->getEffectiveUri() . "\n";
        echo $stats->getTransferTime() . "\n";
        var_dump($stats->getHandlerStats());

        // You must check if a response was received before using the
        // response object.
        if ($stats->hasResponse()) {
            echo $stats->getResponse()->getStatusCode();
        } else {
            // Error data is handler specific. You will need to know what
            // type of error data your handler uses before using this
            // value.
            var_dump($stats->getHandlerErrorData());
        }
    }
]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question