有时候经常会用到一些在线手册,比如国内或国外的,有些是访问速度慢,有些是作者直接吧网站关闭了,有些是服务器总是宕机,所以还是全盘克隆到自己服务器比较爽。所已这里给了一个demo。
<?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'; } }
<?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 ['enableDownload'] = true; $curl->cache ['dir'] = $cacheDir; $curl->cache ['compress'] = true; $clone = new MyCurl_Clone ( $curl, $url, $dir ); $clone->overwrite = true; $clone->start (); return false; } }
对应包含的文件我已经上传上去了http://download.csdn.net/detail/tiaozhanji_xian/8951277,免积分的