理解 wget -r 輸出

理解 wget -r 輸出

這是一個目錄中 tree 指令的輸出:

.
|-- asdf.txt
|-- asd.txt
|-- fabc
|   |-- fbca
|   `-- file1.txt
|-- fldr1
|-- fldr2
|   `-- index.html
|-- fldr3
|   |-- cap.txt
|   `-- f01
`-- out.txt

6 directories, 6 files

我在此目錄中啟動本機 http 伺服器。接下來我執行以下命令:

wget -r -nv --spider --no-parent http://localhost:3000 -o -

....並得到以下輸出:

2017-01-02 20:07:24 URL:http://localhost:3000/ [1580] -> "localhost:3000/index.html" [1]
http://localhost:3000/robots.txt:
2017-01-02 20:07:24 ERROR 404: Not Found.
2017-01-02 20:07:24 URL:http://localhost:3000/fabc/ [897] -> "localhost:3000/fabc/index.html" [1]
2017-01-02 20:07:24 URL:http://localhost:3000/fldr1/ [536] -> "localhost:3000/fldr1/index.html" [1]
2017-01-02 20:07:24 URL:http://localhost:3000/fldr2/ [0/0] -> "localhost:3000/fldr2/index.html" [1]
2017-01-02 20:07:24 URL:http://localhost:3000/fldr3/ [896] -> "localhost:3000/fldr3/index.html" [1]
2017-01-02 20:07:24 URL: http://localhost:3000/asd.txt 200 OK
unlink: No such file or directory
2017-01-02 20:07:24 URL: http://localhost:3000/asdf.txt 200 OK
unlink: No such file or directory
2017-01-02 20:07:24 URL: http://localhost:3000/out.txt 200 OK
unlink: No such file or directory
2017-01-02 20:07:24 URL:http://localhost:3000/fabc/fbca/ [548] -> "localhost:3000/fabc/fbca/index.html" [1]
2017-01-02 20:07:24 URL: http://localhost:3000/fabc/file1.txt 200 OK
unlink: No such file or directory
2017-01-02 20:07:24 URL:http://localhost:3000/fldr3/f01/ [548] -> "localhost:3000/fldr3/f01/index.html" [1]
2017-01-02 20:07:24 URL: http://localhost:3000/fldr3/cap.txt 200 OK
unlink: No such file or directory
Found no broken links.

FINISHED --2017-01-02 20:07:24--
Total wall clock time: 0.3s
Downloaded: 7 files, 4.9K in 0s (43.4 MB/s)
  1. wget 是否寫為永遠尋求index.html?我們可以禁用這個嗎?
  2. 1580、536、0/0 等數字是什麼?
  3. 為什麼這樣說unlink: No such file or directory

答案1

  1. 您可以嘗試使用選項跳過檔案--reject(也接受通配符):

    wget --拒絕index.html

然而你不想這樣做。當使用 wget 時-r,它需要以某種方式取得目錄內的檔案清單。因此,wget 請求index.html 檔案並解析內容,希望取得該目錄中其他檔案的路徑。當資料夾中沒有 index.html 檔案時,網頁伺服器通常會為 wget 產生它 - 該檔案將包含目錄清單。必須在網頁伺服器上啟用此清單檔案的建立 - 否則 wget 將收到 HTTP 404 回覆並因遞歸下載而失敗。

  1. 這是檔案大小(以位元組為單位)。
  2. 這意味著無法刪除檔案(可能是因為它不是首先創建的)。您對使用 wget 下載的目錄有寫入權限嗎?

編輯:在測試 wget 下載後--spider--recursive 我重現了您的取消連結錯誤。看來 wget 使用回應的內容類型來決定檔案是否可以包含指向其他資源的連結。如果內容類型測試失敗且未下載文件,wget 仍將嘗試刪除臨時文件,就像已下載該文件一樣(這在使用 重新運行 wget 時很明顯--debug。它將清楚地說明Removing file due to --spider in recursive_retrieve():)。我猜你已經發現了 wget 中的一個錯誤。

相關內容