CodeIgniter implements the method of fetching pictures from Web sites and automatically downloading them into folders, CodeIgniter crawl
The examples in this article describe the way CodeIgniter implements fetching pictures from a Web site and automatically downloading them to a folder. Share to everyone for your reference. Specific as follows:
Because a site look at the picture compared to the pit father, to page by page pages .... So.... That's what I wrote.
(I am a product is not a programmer) running speed is simply unbearable, and often mistakes occur, so I hope you help improve (PHP).
Of course also welcome to see the version of Python,golang ~ ~ ^_^
1. Controllers:
$this->load->helper (' Date '); $this->load->helper (' phpquery ');//I've put the phpquery file in the helper.
2. View:
This is just for quick product, so write the code directly in the view, ignore the variable name ...
<?php$imageslist = Phpquery::newdocumentfile (' http://g.e-hentai.org/g/xxxxx/xxxxxxx/');//Home $PN = 1;//pages $ps = $ Imageslist->find ('. PTT TD a ');//page navigation//From page navigation start to get page content foreach ($ps as $p) { echo '. $pn + +. ' Page: attr ("href"). ' " />
'; $imagesnow = Phpquery::newdocumentfile (PQ ($p)->attr ("href")); Single page content $images = $imagesnow->find (' #gdt a '),//Grab picture Page List foreach ($images as $image) { echo ' attr (" href "). '" />
'; $imagebigs = Phpquery::newdocumentfile (PQ ($image, $imagesnow)->attr ("href")); Get the single picture page address echo ' Find (' #i3 img ')->attr (' src '). >
';//Output Picture Ob_start (); ReadFile ($imagebigs->find (' #i3 img ')->attr (' src ')); $img = Ob_get_contents (); Ob_end_clean (); $filename = ' img/'. Now (). JPG '; $f =fopen ($filename, ' a '); Fwrite ($f, $img); Fclose ($f); }? >
I hope this article is helpful to everyone based on CodeIgniter PHP program design.
http://www.bkjia.com/PHPjc/1018527.html www.bkjia.com true http://www.bkjia.com/PHPjc/1018527.html techarticle CodeIgniter implementation of the method from the site to grab pictures and automatically download to the folder, CodeIgniter crawl This example tells the CodeIgniter implementation from the site to grab pictures and automatically download to the folder ...