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;
}
}