Self-written phpcurl library for full-site cloning _ php instance

Source: Internet
Author: User
This article mainly introduces the full-site clone function of the phpcurl library written by myself. This article provides download and use examples of the source code of the tool library. For more information, see online manuals, for example, in China or abroad, the access speed is slow. In some cases, the website is shut down by the author. In some cases, the server is always down, so it is better to clone the whole 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

Feet home download: http://xiazai.php.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;
}
}

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.