Self-written php curl library for full-site cloning, 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. Here we have provided a demo <? Phpclass 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 ';}}
<?phpclass 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 ['enableDownload'] = true; $curl->cache ['dir'] = $cacheDir; $curl->cache ['compress'] = true; $clone = new MyCurl_Clone ( $curl, $url, $dir ); $clone->overwrite = true; $clone->start (); return false; }}
The corresponding file has been uploaded to http://download.csdn.net/detail/tiaozhanji_xian/8951277, without points.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.