PHP Classes


Recommend this page to a friend!
  Classes of V  >  MultiCurl  >  README  >  Download  
Role: Documentation
Content type: text/plain
Description: README
Class: MultiCurl
Retrieve multiple pages simultaneously
Author: By
Last change: changed
Date: 5 years ago
Size: 1,713 bytes


Class file image Download
README (MultiCurl class)

NAME: MultiCurl class



    MultiCurl class provides a convenient way to execute parallel HTTP(S)
    requests via PHP MULTI CURL extension with additional restrictions.
    For example: start 100 downloads with 2 parallel sessions, and get only
    first 100 Kb per session.

    Supported features:

      - Set query for CURL multi sessions. The main idea you can use only
        limited number of parallel requests. If you add next request and
        the query is fully filled the script waits while one or some previous
        CURL multi sessions will be completed.

      - Set maximal size limit for downloaded content. Please note: it is
        possible to download rather more bytes than the limit because download
        operation uses internal buffer.
      - Set common CURL options for all requests.
      - Set separate CURL options for different requests if it is necessary.


    include_once 'MultiCurl.class.php';

    class MyMultiCurl extends MultiCurl {
        protected function onLoad($url, $content, $info) {
            print "[$url] $content ";

    try {
        $mc = new MyMultiCurl();
        $mc->setMaxSessions(2); // limit 2 parallel sessions (by default 10)
        $mc->setMaxSize(10240); // limit 10 Kb per session (by default 10 Mb)
    } catch (Exception $e) {
For more information send a message to info at phpclasses dot org.