So I've got a complex problem.  I've been perusing the archives and not seen 
anything resembling a conversation on it, but I may well have missed one.  If 
this is a solved problem, I will apologize and dissapear for the small 
consideration of some pointers to the previous emails.  :D

So, my problem: I want to be able to log in to a secured (https) site via a 
form post.  The problem is the site uses some weird server-side session 
expressed in a different form-post-URL each time I load the login page.  For 
example:

I click on the "login" page, and the page-source form looks like so:

<form name="signin" 
action="https://foo.bar.com:port/UNIQUE_STRING/dir/session.cgi?var=val"; 
AutoComplete="off" method="post">

... various, straight-forward inputs

</form>

where "UNIQUE_STRING" is some string that changes each time I click on the 
login page and view the source.  The first time it might be something like 
"ca1_bn1_on", the next "ca1_eb3_on", etc, with no apparent pattern.

So, what I want to do is automatically surf to the login page (that URL is 
static), then automatically post to the ever-changing form with my particular 
login info filled out.  All that needs to happen in the same session, since 
if I do it via 2 separate wget calls (see below) it fails:

wget https://foo.bar.com:port/login
... various script-magic to extract form post and assemble URL below
wget 
"https://foo.bar.com:port/UNIQUE_STRING/dir/session.cgi?var=val&name=me&pass=foobar&etc...";

... the second call fails - well it connects and the server returns valid 
HTML, but the HTML is the login page with a note of "session logged out - 
please login again".

Now, I don't know how they know to discount the second connect... it doesn't 
look like they're using cookies since when I do a --save-cookies=cookies.txt 
on the first wget call the cookies.txt file is invariably empty (save the 
wget header).

Maybe something to do with the SSL connection?  I don't know, I'm just taking 
shots in the dark there.

I think I may need to be able to do something like:

wget  --recursive --post-data="name=me&password=foo" --follow-tags=form 
https://foo.bar.com:port/login

and have it load the login page, then recursively try to post each form with 
my post-data.  Problem is, that doesn't seem to work.  

Any thoughts?

Thanks!

-Greg



Reply via email to