カールの代わりに aria2 を使用すると、文字列の連結が失われます。

カールの代わりに aria2 を使用すると、文字列の連結が失われます。

ウェブサイトをミラーリングしようとしても遅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を削除する方法は?

ボーナス質問:

  1. URLを処理した後、このページを(再)移動できればいいようです。つまり、インデックスをからに移動./www.example.com/indexします./processed/www.example.com/index。どうすればいいですか?execコマンドに何かがありますかfind?それとも完全なスクリプトが必要ですか?

  2. この目的のために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')

おすすめ記事