Wget downloading incomplete file from a URL [closed]

懵懂的女人 提交于 2019-12-24 08:50:02

问题


I want to get a file downloaded on my linux system whose url is

http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-i586.tar.gz  

and I am issuing the following command as :

wget -U 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:16.0) Gecko/20100101 Firefox/16.0' http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-i586.tar.gz

whereas the user agent is being passed to -U which i have copied from my browser's user agent. But it downloads the file only of size 5.3KB whereas entire file is 46.09MB and the downloaded file is corrupted.

How can I resolve this issue?


回答1:


Looking at the output, you will realize that oracle denied the request, containing following message:

In order to download products from Oracle Technology Network you must agree to the OTN license terms.

Be sure that...

  • Your browser has "cookies" and JavaScript enabled.
  • You clicked on "Accept License" for the product you wish to download.
  • You attempt the download within 30 minutes of accepting the license.

Most probably you have to send some GET or POST value and/or keep session data.




回答2:


The file isn't 'corrupt' exactly; if you go to that URL in a new browser session you'll see an error page saying 'In order to download products from Oracle Technology Network you must agree to the OTN license terms.'. That is the page you've downloaded - the file size of the page it redirects to is 5307 bytes.

Before you can get the file from the download page you have to accept the license agreement using the radio buttons. Doing so creates a cookie in your browser, and when you get the actual file that cookie is checked. wget doesn't have that cookie available.

You need to download directly from the site, or arrange for wget to send a fake cookie, which probably isn't supported in general. Some downloads used to have a wget script attached, not sure if this one does; it doesn't look like it from what's on the download page.



来源:https://stackoverflow.com/questions/21431344/wget-downloading-incomplete-file-from-a-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!