I am trying to use Wget to download a page, but I cannot get past the login screen.
How do I send the username/password using post data on the login page and then download the actual page as an authenticated user?
Based on the manual page:
# Log in to the server. This only needs to be done once.
wget --save-cookies cookies.txt \
--keep-session-cookies \
--post-data 'user=foo&password=bar' \
--delete-after \
http://server.com/auth.php
# Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
http://server.com/interesting/article.php
Make sure the --post-data
parameter is properly percent-encoded (especially ampersands!) or the request will probably fail. Also make sure that user
and password
are the correct keys; you can find out the correct keys by sleuthing the HTML of the login page (look into your browser’s “inspect element” feature and find the name
attribute on the username and password fields).