3
1
I'm trying to download a file from a website that requires login. This command retrieves the cookie.txt and the downloaded html shows I'm logged in (ok):
(I broke the command in lines for readability)
wget
--user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0)
Gecko/20100101 Firefox/45.0"
--keep-session-cookies
--save-cookies cookies.txt
--post-data "login_username=MyUserName&login_password=*******"
--header="Host: somewebsite.com"
--header="Referer: http://somewebsite.com/files/download.php?i=2157716"
http://somewebsite.com/login.php
Here I get cookies.txt. (all ok). And after that: (trying to download)
wget
--user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0)
Gecko/20100101 Firefox/45.0"
--load-cookies cookies.txt
--header="Host: somewebsite.com"
--header="Referer: http://somewebsite.com/files/download.php?i=2157716"
--header="Connection: keep-alive" --header="Accept-Language: en-US,en;q=0.5"
--header="Accept-Encoding: gzip, deflate"
http://somewebsite.com/files/dl.php?t=2157716
But instead of downloading the file it returns an HTML saying that the file can only be downloaded from the website.
Here is the POST data from Firefox right before the download starts:
What is missing?
Could be that the url you think is the download isn't. For example,
wget
doesn't handle javascript redirects. – Ouroborus – 2016-04-05T01:09:08.990