2017-07-18 125 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

的作品就像一個魅力,謝謝 –

相關問題