Home  >  Article  >  Backend Development  >  自己写的php curl库实现整站克隆

自己写的php curl库实现整站克隆

WBOY
WBOYOriginal
2016-06-23 13:29:27980browse

有时候经常会用到一些在线手册,比如国内或国外的,有些是访问速度慢,有些是作者直接吧网站关闭了,有些是服务器总是宕机,所以还是全盘克隆到自己服务器比较爽。所已这里给了一个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; }}

对应包含的文件我已经上传上去了http://download.csdn.net/detail/tiaozhanji_xian/8951277,免积分的


版权声明:本文为博主原创文章,未经博主允许不得转载。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn