wget破坏了内容的配置 [英] wget breaking with content-disposition

查看:126
本文介绍了wget破坏了内容的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从以下网站下载通过Content-Disposition:attachment发送的kml文件:

I am trying to download the kml file that is sent via Content-Disposition:attachment from the following website:

http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia

使用wget和curl命令:

Using wget and curl with the command:

wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia

curl -O -J -L http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia

但是,而不是保存文件作为发送器,它仅保存html内容,并且在发送结束时被卡住。最终返回值是:

However, instead of saving the file being transmitter, it saves only the html content and at the end of the transmission it gets stuck. The terminal return is:

$wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia
[1] 32260
[2] 32261
[3] 32262
work@Aspire-V3-471:~$ --2016-05-13 19:37:54--  http://waterwatch.usgs.gov/index.php?m=real
Resolving waterwatch.usgs.gov (waterwatch.usgs.gov)... 2001:49c8:0:126c::56, 137.227.242.56
Connecting to waterwatch.usgs.gov (waterwatch.usgs.gov)|2001:49c8:0:126c::56|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.php?m=real.5’

    [  <=>                                                                                                                                                  ] 41.637       174KB/s   in 0,2s   

2016-05-13 19:37:55 (174 KB/s) - ‘index.php?m=real.5’ saved [41637]

他们变得很笨拙,我需要按Ctrl + C。
我得到的标头是

And them it got stuch and I need to press Ctrl+C. As the header I get is

HTTP/1.1 200 OK
Date: Sat, 14 May 2016 00:19:21 GMT
Content-Disposition: attachment; filename="real_ia.kml"
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/vnd.google-earth.kml+xml
X-Frame-Options: SAMEORIGIN

I会希望下载 real_ia.kml文件。
使用curl命令也会得到类似的结果。

I would expect to have the 'real_ia.kml' file downloaded. A similar result is given using curl command.

为什么会卡住并且仅下载HTML内容?

Why does it get stuck and downloads only the HTML content?

推荐答案

& 符号被解释为shell特殊字符,导致命令在后台运行(fork )。因此,您应该转义或引用

The & symbols are interpreted as the shell special character which causes a command to run in background(to fork). So you should escape or quote them:

curl -O -J -L 'http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia'

在上面的命令中,我们使用了完整引用

In the command above we used full quoting.

输出的以下几行表示三行命令被派生到背景:

The following lines from your output mean that three commands are being forked to background:

[1] 32260
[2] 32261
[3] 32262

左边的数字(在括号中)是工作编号。您可以通过键入 fg N 将工作放在前台,其中 N 是工作编号。右边的数字是进程ID。

The numbers at the left (in brackets) are job numbers. You can bring a job to foreground by typing fg N, where N is the number of the job. The numbers at the right are process IDs.

这篇关于wget破坏了内容的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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