
ウェブサイトをミラーリングしようとしても遅archive.org
すぎるcurl
ので、一度試してみるかと思いましたaria2
。
まず、このコマンドを使用してWebサイトのリンクグラフを作成します。
wget -c -m --restrict-file-names=nocontrol https://www.example.com/
次に、カールを使用してこのコマンドを実行します。
find . -type f -exec curl -v "https://web.archive.org/save/https://{}" ';'
(私は実際に私がやっていることの十分なログを得るためにこのコマンドを使います。
find . -type f -exec curl -v "https://web.archive.org/save/https://{}" ';' 2> >(grep 'Rebuilt URL' >>/tmp/error ) >/tmp/stdout
-参考用としてここに含まれる)
これはうまくいきます。 find コマンドは次のようなものを生成します。
./www.example.com/index
カールは魔法のように先頭を無視します。./
まあ、Aria2はそれほどスマートではありません。このコマンド
find . -type f -exec aria2c -x 16 -s 1 "https://web.archive.org/save/https://{}" ';'
その結果、次のエラーが発生します。
07/24 23:40:45 [ERROR] CUID#7 - Download aborted. URI=https://web.archive.org/save/https://./www.example.com/index
(追加注./
URLの中央にあります)。
それから私は見つけました。この問題これはfindの出力を修正するのに役立ちました。
find . -type f -printf '%P\n'
返品
www.example.com/index
(リーディングなし./
)
ただし、aria2に供給すると、リンクされたURLがまだ./
真ん中に入っています! ? ! ?
find . -type f -printf '%P\n' -exec aria2c -x 16 -s 1 "https://web.archive.org/save/https://{}" ';'
このエラーメッセージを提供します
www.example.com/index
07/24 23:52:34 [NOTICE] Downloading 1 item(s)
[#d44753 0B/0B CN:1 DL:0B]
07/24 23:52:35 [ERROR] CUID#7 - Download aborted. URI=https://web.archive.org/save/https://./www.example.com/index
Exception: [AbstractCommand.cc:351] errorCode=29 URI=https://web.archive.org/save/https://./www.example.com/index
-> [HttpSkipResponseCommand.cc:232] errorCode=29 The response status is not successful. status=502
07/24 23:52:35 [NOTICE] Download GID#d44753fe24ebf448 not complete:
Download Results:
gid |stat|avg speed |path/URI
======+====+===========+=======================================================
d44753|ERR | 0B/s|https://web.archive.org/save/https://./www.example.com/index
./
正確で正しいURLが提供されているaria2を削除する方法は?
ボーナス質問:
URLを処理した後、このページを(再)移動できればいいようです。つまり、インデックスをからに移動
./www.example.com/index
します./processed/www.example.com/index
。どうすればいいですか?exec
コマンドに何かがありますかfind
?それとも完全なスクリプトが必要ですか?この目的のためにaria2に最適な設定は何ですか?
答え1
最後の-exec
ものは-printf
。
ただし、以下を使用できますxargs
。-exec
find . -type f -printf '%P\n' \
| xargs -I{} aria2c -x 16 -s 1 "https://web.archive.org/save/https://{}"
aria2c
複数のインスタンスを並列に実行することもできますxargs -P <num>
。
find
より良いオプションはaria2
パイプとxargs
。
aria2c -x 16 -s 1 -i <(find . -type f -printf 'https://web.archive.org/save/https://%P\n')
答え2
追加すると、出力のみが生成され、置き換えられたコンテンツは-printf
変更されません。{}
curl
今よりスマートに見える(またはより多くの魔法を適用するように)、検索を開始した最上位ディレクトリに相対的なパス名を生成するために見つかったパス名から最初の文字をaria2
削除します。./
./
find
電話をかけたりaria2
、最初の文字が含まれていないURLを使用したい場合は、次のようにします。curl
./
find . -type f -exec sh -c '
for pathname do
pathname=${pathname#./}
aria2c -x 16 -s 1 "https://web.archive.org/save/https://$pathname"
done' sh {} +
これにより、見つかった複数のパス名を含むサブシェルが呼び出されます。サブシェルはそれを繰り返し呼び出し、./
呼び出す前に標準引数拡張を使用して初期値(この場合)を削除しますaria2c
。
一般的に言うと:
topdir=/some/directory/path # no '/' at the end
find "$topdir" -type f -exec sh -c '
topdir="$1"; shift
for pathname do
pathname=${pathname#$topdir/}
aria2c -x 16 -s 1 "https://web.archive.org/save/https://$pathname"
done' sh "$topdir" {} +
関連: