2017-07-18 87 views
2

即使经历了很多stackoverflow的答案,我找不到解决我的问题。因此我又问了一遍。通过cURL下载文件失败,同时使用chrome工作

我正在尝试使用下面的命令下载http://index-of.es/Magazines/hakin9/books/No.Starch.TCP.IP.Guide.Oct.2005.pdf

curl -o tcp.pdf --cookie coockie -L http://index-of.es/Magazines/hakin9/books/No.Starch.TCP.IP.Guide.Oct.2005.pdf 
--verbose 

输出:

$ curl -o tcp.pdf --cookie coockie -L http://index-of.es/Magazines/hakin9/books/No.Starch.TCP.IP.Guide.Oct.2005.pdf --verbose 
* Adding handle: conn: 0xb65698 
* Adding handle: send: 0 
* Adding handle: recv: 0 
* Curl_addHandleToPipeline: length: 1 
* - Conn 0 (0xb65698) send_pipe: 1, recv_pipe: 0 
    % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
    0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0* About to connect() to index-of.es port 80 (#0) 
* Trying 87.98.231.4... 
* Connected to index-of.es (87.98.231.4) port 80 (#0) 
    0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0> GET /Magazines/hakin9/books/No.Starch.TCP.IP.Guide.Oct.2005.pdf HTTP/1.1 
> User-Agent: curl/7.30.0 
> Host: index-of.es 
> Accept: */* 
> Cookie: 240plan=R130020614; 240planBAK=R2339305415 
> 
< HTTP/1.1 302 Found 
* Replaced cookie 240plan="R130020614" for domain index-of.es, path /, expire 1500391330 
< Set-Cookie: 240plan=R130020614; path=/; expires=Tue, 18-Jul-2017 15:22:10 GMT 
< Date: Tue, 18 Jul 2017 14:20:33 GMT 
* Server Apache is not blacklisted 
< Server: Apache 
< Location: http://index-of.es/ 
< Vary: Accept-Encoding 
< Content-Length: 203 
< Content-Type: text/html; charset=iso-8859-1 
< X-IPLB-Instance: 177 
< 
* Ignoring the response-body 
{ [data not shown] 
100 203 100 203 0  0 166  0 0:00:01 0:00:01 --:--:-- 169 
* Connection #0 to host index-of.es left intact 
* Issue another request to this URL: 'http://index-of.es/' 

我怀疑问题出在地点:http://index-of.es/在HTTP响应,这是不完整的和卷曲递归地尝试连接到相同的位置结束了“返回卷曲:(47)最大(50)重定向跟着

问题:

  • chrome如何下载文件? 如果我使用的命令不完整,还需要在命令中添加哪些内容?

回答

0

看来Curl用户代理已被列入黑名单在该服务器上,改变User-Agent头:

curl -o tcp.pdf \ 
    -H "User-Agent: Mozilla" \ 
    -L "http://index-of.es/Magazines/hakin9/books/No.Starch.TCP.IP.Guide.Oct.2005.pdf" 
+0

的作品就像一个魅力,谢谢 –

相关问题