自己写的php curl库实现整站克隆功能,phpcurl
有时候经常会用到一些在线手册,比如国内或国外的,有些是访问速度慢,有些是作者直接吧网站关闭了,有些是服务器总是宕机,所以还是全盘克隆到自己服务器比较爽。
库特点:
给定一初始连接,初始链接以下的层级所有文件会拷贝到本地。
多次克隆可以配置是否覆盖。
可以配置是否下载图片。
所有链接替换为相对链接,所以可以随便rewrite。
绝对不会出现文件覆盖等问题。
最NB的特点是,没有比这更NB的库了。
SVN:http://svn.phpdr.net/repos/ares/php/library/trunk/lib/CurlMulti/MyCurl/Clone.php
帮客之家下载:http://xiazai.jb51.net/201502/other/CurlMulti.rar
克隆结果展示(这个克隆操作几秒钟就完成了):
克隆源网站:http://www.laruence.com/manual/
克隆结果:http://manual.phpdr.net/yaf/
Demo代码:
复制代码 代码如下:
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';
}
}
复制代码 代码如下:
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;
}
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.