wget 打破 content-disposition
wget breaking with content-disposition
我正在尝试从以下网站下载通过 Content-Disposition:附件发送的 kml 文件:
http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia
通过以下命令使用 wget 和 curl:
wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia
和
curl -O -J -L http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia
但是,它没有保存正在传输的文件,而是仅保存了 html 内容,并且在传输结束时卡住了。终端return是:
$wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=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]
他们收到了 stuch,我需要按 Ctrl+C。
正如我得到的 header 是
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
我希望下载 'real_ia.kml' 文件。
使用 curl 命令给出了类似的结果。
为什么会卡住,只下载 HTML 内容?
&
符号被解释为 shell 特殊字符,它导致命令在后台 运行 (分叉)。所以你应该 escape or quote 他们:
curl -O -J -L 'http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia'
在上面的命令中我们使用了full quoting。
输出中的以下几行表示三个命令正在分叉到后台:
[1] 32260
[2] 32261
[3] 32262
左边(括号内)的数字是职位编号。您可以通过键入 fg N
将作业置于前台,其中 N
是作业的编号。右边的数字是进程ID。
我正在尝试从以下网站下载通过 Content-Disposition:附件发送的 kml 文件:
http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia
通过以下命令使用 wget 和 curl:
wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia
和
curl -O -J -L http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia
但是,它没有保存正在传输的文件,而是仅保存了 html 内容,并且在传输结束时卡住了。终端return是:
$wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=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]
他们收到了 stuch,我需要按 Ctrl+C。 正如我得到的 header 是
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
我希望下载 'real_ia.kml' 文件。 使用 curl 命令给出了类似的结果。
为什么会卡住,只下载 HTML 内容?
&
符号被解释为 shell 特殊字符,它导致命令在后台 运行 (分叉)。所以你应该 escape or quote 他们:
curl -O -J -L 'http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia'
在上面的命令中我们使用了full quoting。
输出中的以下几行表示三个命令正在分叉到后台:
[1] 32260
[2] 32261
[3] 32262
左边(括号内)的数字是职位编号。您可以通过键入 fg N
将作业置于前台,其中 N
是作业的编号。右边的数字是进程ID。