Captures images from a website and automatically downloads them to a folder.
.... 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_^ By the way, the program is based on CodeIgniter .... Click links with caution
- $ This-> load-> helper ('date ');
- $ This-> load-> helper ('phpquery ');
- // I put a single phpQuery file in helper.
- //--This is only for quick output of the product. Therefore, ignore the variable name for the code directly written in the VIEW...
- $ Imageslist = phpQuery: newDocumentFile ('http: // g.e-hentai.org/xxxxx/xxxxxxx/'); // homepage
- $ Pn = 1; // Number of pages
- $ Ps = $ imageslist-> find ('. ptt td a'); // capture the page navigation from the homepage
- // Obtain the page content from the page navigation
- Foreach ($ 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"). '"/>
';
- $ Imagebigs = phpQuery: newDocumentFile (pq ($ image, $ imagesnow)-> attr ("href"); // obtain the address of a single image page
- 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 );
- }
- }
- ?>
|