I want to to download some subtitle files, stored in rar files form http://subs.sab.bz/ The site provides rss feeds for its new releases. Unfortunately, the link provided will open a download page, but will not get the file.

The download page has a button in the middle, and clicking on it will trigger the download of the desired rar file. Anyway, if I right click and copy the link, and try to open it, the browser will open the download page itself, but will not download the file. When I try to use the download link of the file in wget and curl, a php file is downloaded. I read that in such cases a server-side script is used to pass the correct link to the client machine.

So, I am looking for a way to force wget to emulate onclick action of this link. I know html css and javascript enough to find other properties of the download link.

Can this even be done?

PS. I am quite confused why this question was down-voted? Any good explanation, did I break any rules for posting or something, thank you..

  • Possible duplicate: "...automating some web tasks..." -- at least its answers apply, I guess
    – sr_
    Commented Mar 5, 2012 at 10:52
  • 5
    FWIW, that site only does referrer-checking. wget --referer http://subs.sab.bz/ 'http://subs.sab.bz/...&attach_id=1234' got me a RAR file.
    – hhaamu
    Commented Mar 5, 2012 at 12:34
  • Post it as an answer, so I can upvote ans accept it. Thank you. Would like some more info what exactly referer does and is used for, could not comprehend the wiki arcticle
    – deckoff
    Commented Mar 5, 2012 at 12:55
  • I didn't downvote you, but you got downvoted because the question is not very clear. (If a question is against the rules, it usually gets closed.)
    – hhaamu
    Commented Mar 5, 2012 at 16:00

1 Answer 1


You are confusing a few things. "Onclick" actions refer to JavaScript and are client-side. You would have to examine what the JavaScript hook on those links does to unravel the URL. However, there are no onclick actions in play here.

What the web site in question does is referrer checking, also known as "hotlink protection". The browser sends a referrer value by default, and it is the URL of the previous page. This is done so that some other site does not leech off the web site's bandwidth by posting direct links to the files.

If you tried to copy the link and paste it straight to your browser, you would get the same behaviour you are describing in your question, as the browser would not know to send the referrer information then.

The option to tell wget to fake a referrer value is --referer, and -e for curl. The value can usually be safely set to the root of the web site -- the web sites usually don't check that the value is correct that thoroughly:

wget -O output.rar --referer http://subs.sab.bz/ 'http://subs.sab.bz/your-link-here'
  • Thank you :) I was confused, that is right. I supposed there was something happening when I click the download button, hence my onclick assumption.. Thank you for clearing this out for me.
    – deckoff
    Commented Mar 5, 2012 at 16:55
  • I tried this with my ipcam, but without much success. wget -O snapshot.jpg --referer ''. If I translate the output in English, thats "connection established, HTTP-request sent, waiting for reply" Then wget gets stuck. I am sure I use it incorrectly, but how would I download the jpg with bash? Thanks for your help in advance.
    – McPeppr
    Commented Nov 8, 2017 at 21:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .