I have some doubt on wget command. Here is the thing I want to achieve. I want to download a tar package from this link "http://snapshots.linaro.org/oneiric/lt-origen-oneiric/20120321/0/images/hwpack/hwpack_linaro-lt-origen_20120321-0_armel_supported.tar.gz" .. This link is working fine when I am using it in browser to download the package, but when I use the same link to download it through wget command, its redirecting to "http://snapshots.linaro.org/licenses/samsung-v2.html" link which is acceptance of license agreement and instead of downloading the tar file, it is downloading the license agreement file. So, what option should I provide so that it will download the desired tar file and the license agreement file. Please help me on this issue.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You should replicate with wget the same actions you would do with a web browser. The first step is to see what are the http requests that are executed when you ask for the license page, and for the confirm button.
To do this you can use firebug or livehttpheaders. Once you have the urls (with post/get params) you can reproduce it with a shell script and multiple wget calls.
If the website tracks cookies, you will need to instruct wget to keep them in a cookiejar and use said cookiejar for further requests.
In your case the first request is
GET /oneiric/lt-origen-oneiric/20120321/0/images/hwpack/hwpack_linaro-lt-origen_20120321-0_armel_supported.tar.gz HTTP/1.1
for which you get a cookie and a redirect
Set-Cookie: downloadrequested=/oneiric/lt-origen-oneiric/20120321/0/images/hwpack/hwpack_linaro-lt-origen_20120321-0_armel_supported.tar.gz; path=/; domain=.snapshots.linaro.org
Location: http://snapshots.linaro.org/licenses/samsung-v2.html
when you click on the accept button
GET /licenses/samsung-accepted.html HTTP/1.1
you get another cookie and another location (which is the file you want to donwload)
Set-Cookie: samsunglicenseaccepted-v1=true; path=/oneiric/lt-origen-oneiric/20120321/0/images/hwpack/; domain=.snapshots.linaro.org; expires=Wed, 21-Mar-2012 17:37:57 GMT
Location: http://snapshots.linaro.org/oneiric/lt-origen-oneiric/20120321/0/images/hwpack/hwpack_linaro-lt-origen_20120321-0_armel_supported.tar.gz