I am having trouble finding a way to use wget to download a file from a link that uses php to point to the download.
For example, if I want to write a script to download... say superantispyware portable every day so I have a fresh copy all the time (only handy if you run windows, which I don't but I digress) the download link looks like :
I don't want the PHP file, I want the file it links to. In a browser I assume some server side magic happens to make this work. Is there an incantation I can use to emulate what my browser does? can curl do this?
2 Answers
By default, the filename of the URL is used as the target filename. If redirection occurs, it is preferable to use the final filename. That can be accomplished with the --trust-server-names option of wget:
wget --trust-server-names From the manual page of wget:
--trust-server-names
If this is set to on, on a redirect the last component of the redirection URL will be used as the local file name. By default it is used the last component in the original URL.
If the target filename is not what you intended, you can use the -O (long option: --output-document) option as in:
wget -O meh.tar.gz The "magic" is server side, not in the browser, so you just wget or curl the url.