Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
05-01-2009, 11:13 PM #1
- Join Date
- Aug 2007
- Thanked 0 Times in 0 Posts
Parse html file and store images on HTML page into folders
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-01-2009, 11:43 PM #2
- Join Date
- Dec 2005
- Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
- Thanked 637 Times in 625 Posts
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.)