63

This question explains how to do it with curl. The accepted answer also points out that

If wget is available, that would be far simpler.

I looked through man wget but the got lost in there, and didn't find an option to follow redirects.

Vorac
  • 3,077

3 Answers3

57

wget follows redirects automatically. Just give the URL as an argument

wget 'http://downloads.sourceforge.net/project/romfs/genromfs/0.5.2/genromfs-0.5.2.tar.gz'
Matteo
  • 9,796
  • 4
  • 51
  • 66
  • 1
    Oh. I had given it the wrong url and wandering why it is not working. Thanks a lot. – Vorac Aug 16 '13 at 08:18
  • 4
    Sourceforge URL's often need to be quoted due to the &'s in them as well (pre redirect) – Matt Aug 16 '13 at 15:46
  • 2
    Note that when using wget with the SourceForge download URL, the wget output shows the Location: header containing the "real" URL to which the HTTP GET operation is redirected. Copy this URL for subsequent use with HTTP GET agents that cannot follow redirects. – Jonathan Ben-Avraham Dec 28 '15 at 16:38
  • 1
    this does not work anymore: executing your command ends up with a download?use_mirror=vorboss.html file. What is the solution now? – David Portabella Nov 01 '16 at 10:20
  • Doesn't work, HTML is downloaded: ```wget "http://downloads.sourceforge.net/project/romfs/genromfs/0.5.2/genromfs-0.5.2.tar.gz" .... Length: 83592 (82K) [text/html] ....```` – Ross Smith II Feb 14 '17 at 21:21
  • 1
    You have a %22 (") at the end of the URL. I had no problems with wget 'http://downloads.sourceforge.net/project/romfs/genromfs/0.5.2/genromfs-0.5.2.tar.gz' – Matteo Feb 15 '17 at 10:05
  • 1
    @DavidPortabella It's still working. – SmallChess Jul 27 '18 at 14:01
9

Start the download in chrome browser. When it starts cancel it and go to downloads page. You can see the url for the download. Copy it and use it with wget.

  • 2
    This seems to be unnecessarily complicated.  Note that some systems don't have Chrome installed.  Is there any reason why your answer would be preferable over the two-year-old one? – G-Man Says 'Reinstate Monica' Jun 02 '15 at 08:27
  • 1
    Aptly said about chrome. I was just trying to provide a simple trick that might be useful for other sites as well. – Prasanna Kumar Jun 02 '15 at 08:53
  • 3
    Works in Firefox as well. – user5359531 Feb 14 '18 at 04:58
  • 1
    Why "chrome browser"? BTW, this is not convenient for using in a command line environment. Normally, people who use wget are not in a graphical environment. – cedbeu Oct 06 '18 at 22:03
  • Thanks for sharing this trick - I was struggling with getting the actual download URL to used when downloading programmatically. – Raven Oct 01 '20 at 15:52
7

Click the link, you'll get redirected, and you'll see something like "Redirecting... if you are not automatically redirected, click the direct link.

Copy that [direct] link's location, paste it in the command-line like this

wget "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz"

That's it! It worked for me.

Edit: You should omit everything after the '?' character in the url, or else the filename will also have this part.

  • 1
    Doesn't wget automatically follow redirects for you? – Dmitry Grigoryev Nov 17 '15 at 15:11
  • 1
    @DmitryGrigoryev it would, if it were a proper 301/302 redirect. This is a landing page followed by a scripted redirect. – muru Nov 17 '15 at 15:17
  • 1
    Thanks, your post solved my annoying problem. In current sourceforge download page, "direct link" is show if you click the "Problems Downloading?" button. – user802708 Nov 27 '18 at 03:34