wget打破内容处置

时间:2016-05-14 00:50:56

标签: linux curl wget content-disposition

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

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

使用wget和curl命令:

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

$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]

但是,不是将文件保存为发送器,而是仅保存html内容,并且在传输结束时它会卡住。终端返回是:

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

他们很高兴,我需要按Ctrl + C. 我得到的标题是

{{1}}

我希望下载'real_ia.kml'文件。 使用curl命令给出了类似的结果。

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

1 个答案:

答案 0 :(得分:1)

curl -O -J -L 'http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia' 符号被解释为shell特殊字符,它导致命令在后台运行(到fork)。所以你应该escape or quote他们:

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

在上面的命令中,我们使用了full quoting

输出中的以下行表示将三个命令分叉到后台:

fg N

左侧(括号中)的数字是作业编号。您可以通过键入N将作业带到前台,其中ActiveRecord::UnknownAttributeError是作业的编号。右边的数字是进程ID。