task_callback.php 442 B

123456789101112131415161718192021
  1. <?php
  2. require_once '_inc.php';
  3. use Ares333\Curl\Toolkit;
  4. $toolkit = new Toolkit();
  5. $toolkit->setCurl();
  6. $curl = $toolkit->getCurl();
  7. $curl->maxThread = 1;
  8. $curl->onTask = function ($curl) {
  9. static $i = 0;
  10. if ($i >= 50) {
  11. return;
  12. }
  13. $url = 'http://www.baidu.com';
  14. $curl->add(
  15. array(
  16. 'opt' => array(
  17. CURLOPT_URL => $url . '?wd=' . $i ++
  18. )
  19. ));
  20. };
  21. $curl->start();