Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^4: How do I access a password protected site and access data?

by jaydon (Novice)
on Jun 29, 2005 at 18:32 UTC ( [id://471138]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How do I access a password protected site and access data?
in thread How do I access a password protected site and access data?

Hello,

Thank you for your continued interest in my problem.The initial URL takes you to a login page where you are prompted to enter the userID and password. It is not a pop-up window.

Don't know if that makes a difference regarding using LWP. However this morning, I was trying to figure out what was going on by looking at the response headers and it looks like the session cookie that is sent back after the initial GET request is getting sent back in the header of the POST request. However, the server then sends back a second session cookie, and therein lies the problem, as this probably means that the server does not get the userID, password and session ID that is being sent to it with the POST.

I have to temporarily stop working on this but will get back and try installing WWW::Mechanize and see. Will keep you posted.

  • Comment on Re^4: How do I access a password protected site and access data?

Replies are listed 'Best First'.
Re^5: How do I access a password protected site and access data?
by marto (Cardinal) on Jun 30, 2005 at 09:05 UTC
    Hi,

    To get you started I have provided a little example:
    #!/usr/bin/perl use strict; use WWW::Mechanize; my $targeturl="http://www.yourdomain.com/login.asp"; my $mech = WWW::Mechanize->new(); $mech->agent_alias( 'Windows IE 6' ); $mech->get($targeturl); $mech->success or die $mech->response->status_line; $mech->form_number(1); # if the login form was the first form on the p +age $mech->set_fields( username => "MyUserID", password => "Fak3Pa55w0rd" ); $mech->submit(); print $mech->content(); # print content

    I setup an ASP page with a form on it to process the login. The above example logs in and prints out the content of the page following the login.

    Hope this helps

    Martin

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://471138]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found