require_once DIR . '/../vendor/autoload.php';
use QLQueryList;
use QLExtCurlMulti;
$start = time();
$ql = QueryList::getInstance();
//or Custom function name
$ql->use(CurlMulti::class,'curlMulti');
$num = 1;
$ql->curlMulti([
'https://github.com/trending/php',
'https://github.com/trending/go'
])
// 每个任务成功完成调用此回调
->success(function (QueryList $ql,CurlMulti $curl,$r){
echo "Current url:{$r['info']['url']} \r\n";
$data = $ql->find('.p-name>a>em')->texts();
print_r($data->all());
})
// 每个任务失败回调
->error(function ($errorInfo,CurlMulti $curl){
echo "Current url:{$errorInfo['info']['url']} \r\n";
print_r($errorInfo['error']);
})
->start([
// 最大并发数
'maxThread' => 10,
// 错误重试次数
'maxTry' => 3,
]);
报错
Warning: Curl error(60) https://github.com/trending/php inC:\phpspider\queryList\vendor\ares333\php-curl\src\Curl.phpon line279
Warning: Curl error(60) https://github.com/trending/go inC:\phpspider\queryList\vendor\ares333\php-curl\src\Curl.phpon line279