wget 无法正常工作. [英] wget not working properly.

查看:44
本文介绍了wget 无法正常工作.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 wget 命令有些怀疑.这是我想要实现的目标.我想从这个链接http://snapshots.linaro.org/oneiric/lt-origen-oneiric/20120321/0/images/hwpack/hwpack_linaro-lt-origen_20120321-0_armel_supported.tar.gz"下载一个tar包.. 当我在浏览器中使用它下载软件包时,此链接工作正常,但是当我使用相同的链接通过 wget 命令下载它时,它重定向到http://snapshots.linaro.org/licenses/samsung-v2.html"链接,即接受许可协议,不是下载tar文件,而是下载许可协议文件.那么,我应该提供什么选项才能下载所需的 tar 文件和许可协议文件.请帮助我解决这个问题.

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.

推荐答案

您应该使用 wget 复制与使用 Web 浏览器执行的操作相同的操作.第一步是查看当您请求许可页面和确认按钮时执行的 http 请求是什么.

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.

为此,您可以使用 firebuglivehttpheaders.获得 url(带有 post/get 参数)后,您可以使用 shell 脚本和多个 wget 调用来重现它.

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.

如果网站跟踪 cookie,您将需要指示 wget 将它们保存在 cookiejar 中,并使用该 cookiejar 进行进一步请求.

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

你会得到一个 cookie 和一个重定向

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

当您点击接受按钮时

GET /licenses/samsung-accepted.html HTTP/1.1

您获得另一个 cookie 和另一个位置(这是您要下载的文件)

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

这篇关于wget 无法正常工作.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆