Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
LWP::UserAgent Get a page after authenicating SSL

Posted by powersakthi (powersakthi), 29 August 2007
LWP::UserAgent Get a page after authenicating in SSL mode 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  

Posted by KevinAD (KevinAD), 29 August 2007
hmmm...... never mind  

Posted by admin (Graham Ellis), 30 August 2007
Slightly educated wild guess.   You mention an ASP session.   Is there a cookie associated with that which you need to pass on to the second and subsequent POSTs?

Posted by KevinAD (KevinAD), 30 August 2007
Graham,

FYI: this person has been advised about the possibility of needing to send/recieve cookies on two out of four forums he posted this question on. Your suggestion now makes that three. So far he has not replied to any posts on any of the  forums.

Regards,
Kevin

Posted by admin (Graham Ellis), 30 August 2007
Thanks, Kevin ... I tend to look on the bright side and say "oh good - I probably made the right guess"   ... and remember that in some cultures saying "Thank you" does not come naturally.

To be honest, there are times that I enjoy a quick challenge such as this one, so I'll answer even if there might be elements of "spray" posting.  Been around long enough not to expect a response every time.

Posted by KevinAD (KevinAD), 30 August 2007
Yea, I can see you are a generous person when it comes to assisting the people that post questions here (for good reason). I have a good 10 years on forums under my belt so I have seen it all pretty much.

-Kevin



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho