Sometimes, some online brochures are used, for example, domestic or foreign. Some of them are slow to access, some of them are author Direct bar site shut down, some are server always down. So it's cool to clone to your own server. has been given here 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 = ten; $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 files I have uploaded to the http://download.csdn.net/detail/tiaozhanji_xian/8951277, free of points
Write your own PHP Curl library for full site cloning