Captures images from a website and automatically downloads them to a folder.

Source: Internet
Author: User
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

  1. $ This-> load-> helper ('date ');
  2. $ This-> load-> helper ('phpquery ');
  3. // I put a single phpQuery file in helper.

  1. //--This is only for quick output of the product. Therefore, ignore the variable name for the code directly written in the VIEW...
  2. $ Imageslist = phpQuery: newDocumentFile ('http: // g.e-hentai.org/xxxxx/xxxxxxx/'); // homepage
  3. $ Pn = 1; // Number of pages
  4. $ Ps = $ imageslist-> find ('. ptt td a'); // capture the page navigation from the homepage
  5. // Obtain the page content from the page navigation
  6. Foreach ($ ps as $ p)
  7. {
  8. Echo 'quarter '. $ pn ++.' page: attr ("href"). '"/>
    ';
  9. $ Imagesnow = phpQuery: newDocumentFile (pq ($ p)-> attr ("href"); // Single page content
  10. $ Images = $ imagesnow-> find ('# gdt a'); // capture the image page List
  11. Foreach ($ images as $ image)
  12. {
  13. Echo 'attr ("href"). '"/>
    ';
  14. $ Imagebigs = phpQuery: newDocumentFile (pq ($ image, $ imagesnow)-> attr ("href"); // obtain the address of a single image page
  15. Echo 'Find ('# i3 img')-> attr ('src'). '">
    '; // Output image
  16. Ob_start ();
  17. Readfile ($ imagebig-> find ('# i3 img')-> attr ('src '));
  18. $ Img = ob_get_contents ();
  19. Ob_end_clean ();
  20. $ Filename = 'IMG/'.now().'.jpg ';
  21. $ F = fopen ($ filename, 'A ');
  22. Fwrite ($ f, $ img );
  23. Fclose ($ f );
  24. }
  25. }
  26. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.