Reputation: 1472
I'm experimenting with PHP, and I've just asked myself a question. How can I download all images from a single website? Let's say that I wanted and images from cnn.com or any other website. Is there any easy way I can download all the images using PHP, and save them on my local computer (or FTP server).
Any help would be appreciated.
Upvotes: 2
Views: 1532
Reputation: 44969
Not very easy, but not that hard:
Request the page using Curl, parse the HTML using DOMXpath and look for the src
attributes of the images. Then download the images via Curl by adding the full http address to the image path/name.
Upvotes: 4
Reputation: 490153
If you wanted just all download all images referenced by img
elements.
img
element.img
elements and use cURL (or similar) to download each image (check the src
attribute).Upvotes: 0