
これは、1 つのディレクトリでの 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)
- wget は常に seek するように記述されていますか
index.html
? これを無効にすることはできますか? - 1580、536、0/0 などの数字は何ですか?
- なぜそう言うのですか
unlink: No such file or directory
?
答え1
オプションを使用してファイルをスキップすることもできます
--reject
(ワイルドカードも受け入れます):wget --reject index.html
ただし、これは実行しないでください。 で wget を使用する場合-r
、何らかの方法でディレクトリ内のファイルのリストを取得する必要があります。したがって、wget は index.html ファイルを要求し、このディレクトリ内の他のファイルへのパスを取得するためにコンテンツを解析します。フォルダーに index.html ファイルがない場合、通常は Web サーバーが wget 用にそれを生成します。このファイルにはディレクトリ リストが含まれます。このリスト ファイルの作成は Web サーバーで有効にする必要があります。そうしないと、wget は HTTP 404 応答を受信し、再帰ダウンロードで失敗します。
- これはバイト単位のファイル サイズです。
- これは、ファイルを削除できなかったことを意味します (おそらく、最初に作成されなかったためです)。wget を使用してダウンロードしたディレクトリに対する書き込み権限がありますか?
編集:と を使用して wget のダウンロードをテストした後--spider
、--recursive
リンク解除エラーを再現しました。wget は、レスポンスのコンテンツ タイプを使用して、ファイルに他のリソースへのリンクを含めることができるかどうかを判断しているようです。コンテンツ タイプのテストが失敗し、ファイルがダウンロードされない場合、wget は、ダウンロードされたかのように一時ファイルを削除しようとします (これは、を使用して wget を再実行すると明らかです--debug
。 が明確に示されますRemoving file due to --spider in recursive_retrieve():
)。wget のバグが見つかったと思います。