I have the following code to retrieve a page from a website that needs authentication (it uses Sungard Higher Education authentication):
wget --delete-after --save-cookies cookies.txt --keep-session-cookies --post-data 'user=foo&password=bar&uuid=0x123' login.php
wget --load-cookies cookies.txt thepage.com
But the problem is that the second one doesn't work. When I run the first one, it says I was successfully logged in but I get login required on the second.
I tried matching the POST/GET calls to be exactly like that on the browser by adding --header
for each header I got from the HTTP call extracted from Chrome's developer tools, but it still didn't work.
I think the problem is that the authentication isn't cookies-based, and I'm opening a new session with each wget call. How would I prevent that from happening (if that's what happening)?
I think what I want to do is send the HTTP request and basically "navigate" to the page, which I'd imagine is one wget call, but I really don't know how to do it.
Best Answer
Using the
--input-file
switch and feeding it a text file containing your URL(s) should allow you to use only one wget invocation/session with all the other switches you need.