Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
    
Possible duplicate: "...automating some web tasks..." -- at least its answers apply, I guess –  sr_ Mar 5 '12 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 Mar 5 '12 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 Mar 5 '12 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 Mar 5 '12 at 16:00

1 Answer 1

up vote 4 down vote accepted

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'
share|improve this answer
    
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 Mar 5 '12 at 16:55

Your Answer

 
discard

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.