Example #1
0
 public function getContent()
 {
     $curl = new Core();
     // 链接数据库
     require '/www/html/workerman/html/cl_spider/zreading/vendor/indieteq/indieteq-php-my-sql-pdo-database-class/Db.class.php';
     $db = new Db();
     $list = $db->query("SELECT id, detail_url,source_id from list limit 10");
     if ($list) {
         foreach ($list as $k => $v) {
             $curl->add(array('url' => $v['detail_url']), 'Content::callback1');
         }
     }
     $curl->start();
 }
Example #2
0
<?php

require_once '../vendor/autoload.php';
use Ares333\CurlMulti\Core;
$curl = new Core();
$curl->opt[CURLOPT_RETURNTRANSFER] = false;
$url = 'http://www.baidu.com';
$curl->add(array('url' => $url, 'opt' => array(CURLOPT_RETURNTRANSFER => true)), function ($r, $args) {
    echo "content length: " . strlen($r['content']);
});
$curl->start();
Example #3
0
<?php

require_once '../../vendor/autoload.php';
use Ares333\CurlMulti\Core;
$url = array();
$curl = new Core();
$curl->start(function () {
    static $i = 0;
    echo $i++ . "\n";
    if ($i >= 7) {
        return false;
    }
    sleep(1);
    return true;
});