adl*_*tta 5 linux curl wget content-disposition
我正在尝试从以下网站下载通过 Content-Disposition:attachment 发送的 kml 文件:
\n\nhttp://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia\nRun Code Online (Sandbox Code Playgroud)\n\n将 wget 和curl 与命令一起使用:
\n\nwget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia\nRun Code Online (Sandbox Code Playgroud)\n\n和
\n\ncurl -O -J -L http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia\nRun Code Online (Sandbox Code Playgroud)\n\n然而,它不保存正在发送的文件,而是仅保存 html 内容,并且在传输结束时它会卡住。终端返回为:
\n\n$wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia\n[1] 32260\n[2] 32261\n[3] 32262\nwork@Aspire-V3-471:~$ --2016-05-13 19:37:54-- http://waterwatch.usgs.gov/index.php?m=real\nResolving waterwatch.usgs.gov (waterwatch.usgs.gov)... 2001:49c8:0:126c::56, 137.227.242.56\nConnecting to waterwatch.usgs.gov (waterwatch.usgs.gov)|2001:49c8:0:126c::56|:80... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: unspecified [text/html]\nSaving to: \xe2\x80\x98index.php?m=real.5\xe2\x80\x99\n\n [ <=> ] 41.637 174KB/s in 0,2s \n\n2016-05-13 19:37:55 (174 KB/s) - \xe2\x80\x98index.php?m=real.5\xe2\x80\x99 saved [41637]\nRun Code Online (Sandbox Code Playgroud)\n\n他们变得如此,我需要按 Ctrl+C。\n因为我得到的标题是
\n\nHTTP/1.1 200 OK\nDate: Sat, 14 May 2016 00:19:21 GMT\nContent-Disposition: attachment; filename="real_ia.kml"\nKeep-Alive: timeout=5, max=100\nConnection: Keep-Alive\nTransfer-Encoding: chunked\nContent-Type: application/vnd.google-earth.kml+xml\nX-Frame-Options: SAMEORIGIN\nRun Code Online (Sandbox Code Playgroud)\n\n我希望下载“real_ia.kml”文件。\n使用curl 命令给出类似的结果。
\n\n为什么会卡住并且只下载 HTML 内容?
\n这些&符号被解释为 shell 特殊字符,它导致命令在后台运行(fork)。所以你应该转义或引用它们:
curl -O -J -L 'http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us®ions=ia'
Run Code Online (Sandbox Code Playgroud)
在上面的命令中,我们使用了完整引用。
输出中的以下几行意味着三个命令被分叉到后台:
[1] 32260
[2] 32261
[3] 32262
Run Code Online (Sandbox Code Playgroud)
左边的数字(括号内)是职位编号。您可以通过键入 来将作业调至前台fg N,其中N是作业编号。右边的数字是进程 ID。