View Full Version : Parse html file and store images on HTML page into folders

05-02-2009, 12:13 AM

Looking for a quick solution.

I want to create a PHP5 program to run from command line.

Here is what it needs to do.

1. Search entire HTML code.
2. When locates an <IMG> tag, take that image and domain (http://www.cnn.com/turkey.jpg), create a folder on my desktop and place the image into that folder in a directory named as the domain (the folder would be named "cnn.com" and the image placed in it would be "turkey.jpg").


05-02-2009, 12:43 AM
Any solution will not be quick, but rather very involved.

You'll need to scrape the website:


Then you'll need to send an http request to get the image. Something like CURL can help you with this:


Then you'll have to save the image on your web server first, then FTP the image to your local computer, which will only work if your local computer has an FTP server installed. (For security reasons there's no way for PHP to copy a file to the client machine directly.)