Write your own PHP Curl library to achieve the entire station cloning function, Phpcurl
Sometimes the use of some online manuals, such as domestic or foreign, some are slow access, some are the author of the direct bar site is closed, some servers are always down, so or the overall cloning to their own server relatively cool.
Library Features:
Given an initial connection, all files are copied locally at the level below the initial link.
Multiple clones can be configured to overwrite.
You can configure whether to download pictures.
All links are replaced by relative links, so you can rewrite them casually.
There is absolutely no file overwrite issues.
The most NB feature is that there is no more NB library than this.
svn:http://svn.phpdr.net/repos/ares/php/library/trunk/lib/curlmulti/mycurl/clone.php
Help Home Download: Http://xiazai.jb51.net/201502/other/CurlMulti.rar
Cloning results display (this cloning operation is completed in seconds):
Clone source Web site: http://www.laruence.com/manual/
Clone Result: http://manual.phpdr.net/yaf/
Demo code:
Copy the code code as follows:
<?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 ';
}
}
Copy the Code code as follows:
<?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://www.bkjia.com/PHPjc/957129.html www.bkjia.com true http://www.bkjia.com/PHPjc/957129.html techarticle write their own Php Curl library to achieve the entire site cloning function, Phpcurl sometimes use some online manuals, such as domestic or foreign, some are slow access, some are the author of the direct network ...