Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to mirror a website.

It follows a simple scheme of .htm files but there is one catch. Each file contains the following line:

<img width="100%" src="">

I need to download this image, but httrack and wget both ignore the script outputs when downloading a file.

The php script does not take any parameters. It determines which image to output internally. Each .htm file gets a different output. So I can't simply call the php file. It needs to be downloaded as some kind of dependency of the corresponding .htm file.

How can I configure wget or httrack or really any other tool to get what I need?

share|improve this question

You can't download and run the .php since it is supposed to run server-side.

If the website is such as:

<img width="100%" src="">

When you get the page source you can't actually see that (client-side). What you should see is:

<img width="100%" src="">

You could then wget the html, parse it, and download the image. You have to either know the pattern of the filename or the possible extensions. If you don't, you can iterate over a list of possible extensions. For only one image it should look something like this:

# Get the html for us to parse
wget -O index.html
# List of common image extensions
exts=("png" "jpg" "jpeg" "bmp" "gif")
for ext in ${exts[@]}
    # Parse the html looking for an image
    # You'll have to adapt the regex, of course
    # man grep to see what each letter stands for
    img=`grep -shoiP "DOMAIN\.org/.+\.${ext}" index.html`
    if [ "$img" = "" ]
wget $img

Of course you'll have to adapt that.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.