Write your own phpcurl library to implement the whole site cloning function. phpcurl_PHP tutorial

Source: Internet
Author: User
The self-written phpcurl library implements the whole-site cloning function, phpcurl. You can write your own phpcurl library to clone the whole site. phpcurl sometimes uses online manuals, such as domestic or foreign ones, which are slow to access, some of them are php curl libraries written by the author to achieve the whole site cloning function, phpcurl

Sometimes some online manuals, such as those in China or abroad, are frequently used. some of them are slow access speeds. some of them are caused by direct website shutdown, and some are caused by server downtime, therefore, it is better to clone the entire server to your own server.

Kutetes:

Given an initial connection, all objects at the level below the initial link will be copied to the local device.
You can configure whether to overwrite multiple clones.
You can configure whether to download images.
Replace all links with relative links, so you can rewrite them as needed.
No issues such as file overwrite will occur.
The most characteristic of NB is that there is no more NB library than this.

SVN: http://svn.phpdr.net/repos/ares/php/library/trunk/lib/CurlMulti/MyCurl/Clone.php

Help house Download: http://xiazai.jb51.net/201502/other/CurlMulti.rar

Clone result Display (this clone operation is completed in seconds ):

Kelon source site: http://www.laruence.com/manual/
Clone result: http://manual.phpdr.net/yaf/

Demo code:

The code is as follows:


<? Php
Class Controller_Spider extends MyYaf_Controller_Base {
Function init (){
Parent: init ();
If (! $ This-> getRequest ()-> isCli ()){
Ares_Http: error403 ();
}
Include 'curlmulti/CurlMulti. php ';
Include 'curlmulti/MyCurl. php ';
Include 'phpquery. php ';
}
}

The code is as follows:


<? Php
Class YafdocController extends Controller_Spider {
Function init (){
Parent: init ();
Include 'curlmulti/MyCurl/Clone. php ';
}
Function indexAction (){
$ Url = 'http: // www.laruence.com/manual ';
$ Dir = Yaf_Application: app ()-> getAppDirectory (). '/data/manual ';
$ CacheDir = $ this-> getBaseDir (). '/cache/curl ';
If (! Is_dir ($ cacheDir )){
Mkdir ($ cacheDir );
}
$ Curl = new CurlMulti ();
$ Curl-> maxThread = 10;
$ Curl-> cache ['enable'] = true;
$ Curl-> cache ['enablesdownload'] = true;
$ Curl-> cache ['dir'] = $ cacheDir;
$ Curl-> cache ['compus'] = true;
$ Clone = new MyCurl_Clone ($ curl, $ url, $ dir );
$ Clone-> overwrite = true;
$ Clone-> start ();
Return false;
}
}

The curl library implements the whole site cloning function. phpcurl sometimes uses some online manuals, such as domestic or foreign ones. some of them are slow access speeds, and some are direct access speeds...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.