47

wgetを使用して、このURLでファイルをリモートでダウンロードしたいと思います。

https://test.mydomain.com/files/myfile.zip

サイトtest.mydomain.comにはログインが必要です。このコマンドを使用して別のサーバーにそのファイルをダウンロードしたいのですが、機能しません(ファイルを完全にダウンロードしません):

wget --user=myusername --password=mypassword https://test.mydomain.com/files/myfile.zip

私のユーザー名がmyusernameで、パスワードがmypasswordの場合、正しいwget構文は何でしょうか?

上記のコマンドを入力した後の戻りメッセージは次のとおりです。

Resolving test.mydomain.com (test.mydomain.com)... 123.456.789
Connecting to test.mydomain.com (test.mydomain.com)|123.456.789|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://test.mydomain.com/login/unauthorized [following]
--2013-01-30 02:01:32--  https://test.mydomain.com/login/unauthorized
Reusing existing connection to test.mydomain.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://test.mydomain.com/login [following]
--2013-01-30 02:01:32--  https://test.mydomain.com/login
Reusing existing connection to test.mydomain.com:443.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `myfile.zip'

私は何かが足りないのですか?助けてください。ありがとう。

4

4 に答える 4

91

オプション--userおよび--ask-passwordを指定すると、wgetは資格情報を要求します。以下に例を示します。ユーザー名とダウンロードリンクを必要に応じて変更します。

wget --user=username --ask-password https://xyz.com/changelog-6.40.txt
于 2013-01-30T02:19:46.703 に答える
24

おそらくHTTP1.0にのみ準拠しているため、wgetが一部のサーバーで適切に認証されないことがわかりました。このような場合、curl(HTTP 1.1準拠)は通常、次のトリックを実行します。

curl -o <filename-to-save-as> -u <username>:<password> <url>

于 2013-06-11T18:26:32.507 に答える
11

ファイルが部分的にダウンロードされているわけではありません。認証に失敗するため、たとえば「index.html」をダウンロードしますが、myfile.zipという名前を付けます(これがダウンロードしたいものであるため)。

私は@thomasbabujによって提案されたリンクをたどり、最終的にそれを理解しました。

追加--auth-no-challengeしてみてください。@thomasbabujが提案したように、パスワードエントリを置き換えてください。

つまり

wget --auth-no-challenge --user=myusername --ask-password https://test.mydomain.com/files/myfile.zip
于 2016-01-18T13:30:02.810 に答える
2

HTTPSの代わりにHTTPで同じアドレスを試すことができます。これはHTTPSではなくHTTPを使用し、一部のサイトのみがこの方法をサポートしている可能性があることに注意してください。

アドレスの例:https ://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.3.0-amd64-netinst.iso

wget http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.3.0-amd64-netinst.iso

*のhttp://代わりに注意してhttps://ください。

これはおそらくお勧めできません:)

可能であれば、curlを使用してみてください。


編集:

参考までに、ユーザー名(およびパスワードの入力を求めるプロンプト)の例は次のようになります。

curl --user $USERNAME -O http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.3.0-amd64-netinst.iso

どこ-Oにありますか

 -O, --remote-name
              Write output to a local file named like the remote file we get. (Only the file part of the remote file is used, the path is cut off.)
于 2020-03-31T05:34:28.920 に答える