CodeIgniter captures images from a website and automatically downloads them to folders.
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: <a href = "'. pq ($ p)-> attr ("href "). '"/> </br>'; $ 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' <a hr Ef = "'. pq ($ image, $ imagesnow)-> attr ("href "). '"/> </br>'; $ imagebig = phpQuery: newDocumentFile (pq ($ image, $ imagesnow)-> attr (" href ")); // obtain the page address of a single image echo ' find ('# i3 img')-> attr ('src '). '"> </br>'; // 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); fcl Ose ($ f) ;}}?>
I hope this article will help you with CodeIgniter-based php programming.