Ich habe einen einfachen Befehl, um eine angemeldete Seite mit allen Abhängigkeiten abzurufen:
wget --post-data='user=user&password=password' --page-requisites https://…/login
Das Serverprotokoll zeigt Folgendes (aus offensichtlichen Gründen gekürzt):
- POST /Anmeldung 302
- GET /Konto 200
- POST /robots.txt 200 (sollte ein GET sein, aber es gelingt, also kein Problem)
- POST /favicon.ico 200 (ebenfalls)
- POST /[laaaange PageSpeed-URL]500 (für jede CSS-, JavaScript- und Bilddatei auf der Seite)
Das Abrufen dieser Dateien funktioniert einwandfrei, die URLs sind also korrekt, aber PageSpeed mag es anscheinend nicht, wenn Clients POSTs senden.Wie kann ich wget
GET für alles außer der ersten Anfrage verwenden?
Verwende GNU Wget 1.18.
Aktualisieren:Insekteingereicht.
Antwort1
Von „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.