CodeIgniter captures images from websites and automatically downloads them to folders. CodeIgniter can capture images from websites and automatically download them to folders, codeigniter captures images from the website and automatically downloads the images to the folder. CodeIgniter captures images from the website and automatically downloads the images to the folder.
This example describes how CodeIgniter can capture images from a website and automatically download them to a folder. Share it with you for your reference. The details are as follows:
Because a website looks at a poor picture, it needs a one-page flip .... So .... I wrote something like this.
(I am a product rather than a programmer) the running speed is simply intolerable, and errors often occur, so I hope you can help improve (PHP ).
Of course, you are also welcome to see PYTHON and GOLANG versions ~~ Pai_^
1. controllers:
$ This-> load-> helper ('date'); $ this-> load-> helper ('phpquery'); // I put a single phpQuery file in helper.
2. view:
This is only for quick output of the product, so the code written directly in the VIEW should be ignored...
<? Php $ imageslist = phpQuery: newDocumentFile ('http: // g.e-hentai.org/xxxxx/xxxxxxx/'); // Home Page $ pn = 1; // page number $ ps = $ imageslist-> find ('. ptt td a'); // capture the page navigation from the homepage // Obtain the page content from the page navigation ($ ps as $ p) {echo 'quarter '. $ pn ++. 'page: attr ("href "). '"/>
'; $ Imagesnow = phpQuery: newDocumentFile (pq ($ p)-> attr ("href ")); // Single Page Content $ images = $ imagesnow-> find ('# gdt a'); // capture the image page list foreach ($ images as $ image) {echo 'attr ("href "). '"/>
'; $ Imagebig = phpQuery: newDocumentFile (pq ($ image, $ imagesnow)-> attr ("href ")); // Obtain the page address of a single image echo 'Find ('# i3 img')-> attr ('src '). '">
'; // Output image ob_start (); readfile ($ imagebig-> 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 will help you with CodeIgniter-based php programming.
Examples of this article describes how CodeIgniter can capture images from websites and automatically download images to folders...