2017 © Pedro Peláez
 

library multi-curl

multiCurl 多线程curl

image

luojixinhao/multi-curl

multiCurl 多线程curl

  • Friday, June 22, 2018
  • by luojixinhao
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

关于

利用curl_multi_*系列函数+回调达到多线程采集。, (*1)

需求

PHP 5.3 +, (*2)

安装

composer require luojixinhao/multi-curl:*, (*3)

联系

Email: lx_2010@qq.com
, (*4)

示例

<?php

use luojixinhao\mCurl;

$mc = new multiCurl();
$mc->add('http://proxyip.9window.com/api/getproxyiplist/10');
$mc->add('http://im.qq.com/album/');
$re = $mc->run(4); //不使用回调,直接返回结果
print_r($re);
<?php

use luojixinhao\mCurl;

$conf = array(
    'maxTry' => 2, //失败尝试次数
    'maxConcur' => 5, //最大并发数
);
$mc = new multiCurl($conf);
$mc->add('http://proxyip.9window.com/api/getproxyiplist/10', array(
    CURLOPT_USERAGENT => 'test',
), array(
    'arg1' => 'testArg'
), function($url, $content, $args, $header, $errorno, $error){
    //成功时的回调
    print_r(func_get_args());
}, function($url, $content, $args, $header, $errorno, $error){
    //失败时的回调
    print_r(func_get_args());
});
$mc->run();
<?php

use luojixinhao\mCurl;

$mc = new multiCurl();
//先运行再动态添加
$mc->run(function() use ($mc) {
    $mc->add('http://proxyip.9window.com/api/getproxyiplist/10', null, null,
        function($url, $content, $args, $header, $errorno, $error) {
        //成功时的回调
        print_r(func_get_args());
    }, function($url, $content, $args, $header, $errorno, $error) {
        //失败时的回调
        print_r(func_get_args());
    });
});
<?php

use luojixinhao\mCurl;

$mc = new multiCurl();
//不停采集某个地址,当采集大于10次后停止
$mc->run(function($mc) {
    $mc->add('http://im.qq.com/album/', null, null,
        function($url, $content, $args, $header, $errorno, $error) {
        //成功时的回调
        print_r(func_get_args());
    }, function($url, $content, $args, $header, $errorno, $error) {
        //失败时的回调
        print_r(func_get_args());
    });

    if ($mc->getInfos('finishNum') >= 10) {
        return false;
    }
    return true;
});

The Versions

22/06 2018

dev-master

9999999-dev https://github.com/luojixinhao/multi-curl

multiCurl 多线程curl

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

curl multicurl curlmulti

10/10 2017

1.3.1

1.3.1.0 https://github.com/luojixinhao/multi-curl

multiCurl 多线程curl

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

curl multicurl curlmulti

15/09 2017

V1.3

1.3.0.0 https://github.com/luojixinhao/multi-curl

multiCurl 多线程curl

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

curl multicurl curlmulti

13/09 2017

V1.2

1.2.0.0 https://github.com/luojixinhao/multi-curl

multiCurl ¶àÏß³Ìcurl

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

curl multicurl curlmulti

13/09 2017

V1.1

1.1.0.0 https://github.com/luojixinhao/multi-curl

multiCurl ¶àÏß³Ìcurl

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

curl multicurl curlmulti

13/09 2017

V1.0

1.0.0.0 https://github.com/luojixinhao/multiCurl

multiCurl

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

curl multicurl curlmulti