CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
LWP::UserAgent Get a page after authenicating SSL

 



powersakthi
New User

Aug 29, 2007, 6:29 AM

Post #1 of 3 (1933 views)
LWP::UserAgent Get a page after authenicating SSL Can't Post

Hi All,
I am using LWP::UserAgent and HTML::TreeBuilder to communicate to the below site
Here is the website map:

https://secure.server.com/index.htm which asks for two fields
user_id
user_pwd
then submit button
the form is submitted to
https://secure.server.com/login.asp
which validates the login credentials and if validated then user is redirected to main.asp and there will be a link called
https://secure.server.com/data.asp
which will have field
tx_Sno
and after typing the serialnumber and hitting submit button the data is POST'ed to data.asp and details like
1) Manufacured_date
2) Model
3) Site .e.t.c comes in a tabular format.

Now the requirement:
I have to write a perl script which will do all these jobs behind the screen using LWP::UserAgent and use HTML::TreeBuilder. Since the site is SSL based i used CRYPT:SSLeay. Now my program looks like this

use strict;
use warnings;
use LWP::UserAgent;
use HTML::TreeBuilder;

my $ua = LWP::UserAgent->new( agent => 'Mozilla/5.0' );

my $response1 = $ua->post(
'https://secure.server.com/login.asp ', [
"user_id" => "anonymous",
"user_pwd" => "password",
]
);

my $response = $ua->post(
'https://secure.server.com/data.asp', [
"tx_Sno" => "T450W34990",
]
);
print $response->status_line;
print $response1->status_line;
print $response->content;
print $response1->content;

The output is Status ok but the login data.asp is not getting into the session and it returns the response..
<SCRIPT>
parent.document.location.replace('/index.htm');
</SCRIPT>
which means the session created by response1 is not applying to response POST. Can anyone help me how to handle this situation...


KevinR
Veteran


Aug 29, 2007, 9:50 AM

Post #2 of 3 (1931 views)
Re: [powersakthi] LWP::UserAgent Get a page after authenicating SSL [In reply to] Can't Post

I don't have much experience in this area, but I see you are doing this:


Code
my $response1 = $ua->post( 
'https://secure.server.com/login.asp ', [
"user_id" => "anonymous",
"user_pwd" => "password",
]
);


have you tried like this:


Code
my $response1 = $ua->post( 
'https://secure.server.com/login.asp ',
"user_id" => "anonymous",
"user_pwd" => "password",
);


or any other variations? The next obvious question is are the real form field names correct and the 'id' and 'password' correct? Additionaly, do you need to send or recieve cookies?
-------------------------------------------------


KevinR
Veteran


Aug 29, 2007, 9:57 AM

Post #3 of 3 (1929 views)
Re: [powersakthi] LWP::UserAgent Get a page after authenicating SSL [In reply to] Can't Post

I see you have this posted on another forum. I will not post anymore replies here, if I have anything further to add I will post on the other forum.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives