ページの必要なコンテンツを取得するために `wget`にGETメソッドを使用させるにはどうすればよいですか?

ページの必要なコンテンツを取得するために `wget`にGETメソッドを使用させるにはどうすればよいですか?

ログインページとすべての依存関係を取得する簡単なコマンドがあります。

wget --post-data='user=user&password=password' --page-requisites https://…/login

サーバーログには次のものが表示されます(明白な理由で省略されています)。

  1. 公開/ログイン 302
  2. get/account200
  3. POST /robots.txt 200(GETでなければなりませんが成功したため問題ありません)
  4. POST /favicon.ico 200(上記と同じ)
  5. POST / [looong PageSpeed URL]500(ページ内のすべてのCSS、JavaScript、および画像ファイルについて)

これらのファイルをインポートするのはうまくいくので、URLは正確ですが、PageSpeedはクライアント側のPOSTが好きではないようです。wget初期リクエスト以外のすべてのアイテムに対してGETをどのように使用できますか?

GNU Wget 1.18を使用してください。


修正する:抜け穴提出された。

ベストアンサー1

"man wget"から:

           This example shows how to log in to a server using POST and then proceed to download the desired pages, presumably only accessible to authorized
       users:

               # Log in to the server.  This can be done only once.
               wget --save-cookies cookies.txt \
                    --post-data 'user=foo&password=bar' \
                    http://example.com/auth.php

               # Now grab the page or pages we care about.
               wget --load-cookies cookies.txt \
                    -p http://example.com/interesting/article.php

       If the server is using session cookies to track user authentication, the above will not work because --save-cookies will not save them (and neither
       will browsers) and the cookies.txt file will be empty.  In that case use --keep-session-cookies along with --save-cookies to force saving of session
       cookies.

おすすめ記事