我使用goutte但未应用CURLOPT_TIMEOUT设置

时间:2016-01-07 05:29:15

标签: php curl goutte

PHP代码

<?php

set_time_limit(0);

/**
 * Todo: Send a random user agent string and sleep a random amount between requests.
 */
// Extract and sanatize input:
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_URL);
$terms = filter_input(INPUT_POST, 'terms', FILTER_SANITIZE_STRING);

//require_once('./goutte-v1.0.7.phar');
require_once('./goutte-v2.0.4.phar');

include_once('./config.php');

$client = new Goutte\Client;
$result = null;


$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_TIMEOUT, 0);
$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_TIMEOUT_MS, 0);
$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_CONNECTTIMEOUT, 0);
$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_RETURNTRANSFER, true);

..
.. mysql process
..


while($row = sql_fetch_array($selResult)) {
    $sTime = time();

    $IDX = $row['IDX'];
    $THREAD_URL = $row['THREAD_URL'];

    $crawler = $client->request('GET', $THREAD_URL);

    ..
    ..
    ..
    ..
    ..

错误消息

PHP Fatal error:  Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 28: Operation timed out after 30031 milliseconds with 0 bytes received [url] http://target_domain' in phar:///home/myaccount/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php:359
Stack trace:
#0 phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php(292): Guzzle\Http\Curl\CurlMulti->isCurlException(Object(Guzzle\Http\Message\Request), Object(Guzzle\Http\Curl\CurlHandle), Array)
#1 phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php(257): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\Request), Object(Guzzle\Http\Curl\CurlHandle), Array)
#2 phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php(240): Guzzle\Http\Curl\CurlMulti->processMessages()
#3 phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/ in phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php on line 359

Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 28: Operation timed out after 30031 milliseconds with 0 bytes received [url] http://target_domain' in phar:///home/myaccount/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php:359
Stack trace:
#0 phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php(292): Guzzle\Http\Curl\CurlMulti->isCurlException(Object(Guzzle\Http\Message\Request), Object(Guzzle\Http\Curl\CurlHandle), Array)
#1 phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php(257): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\Request), Object(Guzzle\Http\Curl\CurlHandle), Array)
#2 phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php(240): Guzzle\Http\Curl\CurlMulti->processMessages()
#3 phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/ in phar:///home/moya/www/scrap/goutte-v1.0.7.phar/vendor/guzzle/http/Guzzle/Http/Curl/CurlMulti.php on line 359

有人可以帮忙吗?

0 个答案:

没有答案