Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parse html file and store images on HTML page into folders

    Hello,

    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").

    Thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Any solution will not be quick, but rather very involved.

    You'll need to scrape the website:

    http://en.wikipedia.org/wiki/Screen_scraping

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

    http://us.php.net/manual/en/book.curl.php

    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.)

    http://us.php.net/manual/en/wrappers.ftp.php


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •