Help with a "Post" procedure

J

Jim Simpson

Some of these postings got lost and I have tried to reassemble them.
Jim

I am trying to automate loging in to an HTTPS site which requires a "user
name" and "password". It appears to me that the following code should do the
job - but it does not do it. Can someone help me out on this.

I'm especially concerned about the "post" line. I do not understand what
should be in the places where I have used 'text', 'password' and 'submit'.

All help will be greatly appreciated.

Jim

#########################
#A program to login to a secure site which requires a "user name" and
password".
#Load the source code of the site into a Microsoft Word document.
#Using Windows 98 and ActivePerl v5.8
#########################

use strict;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Cookies;
use Win32::OLE::Const 'Microsoft Word';

my $https_login = 'url of login sheet sought';
my $https_user = 'my user name';
my $https_pass = 'my password';

#get already active Word application or open new
my $Word = Win32::OLE->GetActiveObject('Word.Application')
||Win32::OLE->new('Word.Application', 'Quit');

my $book = $Word->Documents("PrintOut.doc");

# secure login
my $ua = LWP::UserAgent->new();
$ua->protocols_allowed( [ 'https'] );
$ua->cookie_jar(HTTP::Cookies->new(file => ".cookies.txt", autosave =>
1));
my $response = $ua->post($https_login, [ 'text' => "$https_user",
'password' => "$https_pass", 'submit' => "Log On" ] );

$book->words(1)->{'text'} = Dumper($response);


From: Matt Garrish ([email protected])
Subject: Re: Help with a "Post" procedure.


Newsgroups: comp.lang.perl.misc
Date: 2004-06-18 14:51:24 PST


Jim Simpson said:
I am trying to automate logging in to an HTTPS site which requires a "user
name" and "password". It appears to me that the following code should do the
job - but it does not do it. Can someone help me out on this.

I'm especially concerned about the "post" line. I do not understand what
should be in the places where I have used 'text', 'password' and 'submit'.

You need to take a step back and learn some basic html. When you submit a
form, each field has (should have!) a name (i.e., <input name="somthing">)
which is used to identify the variable(s) being sent to the server. Username
and password are often used for fields on login pages, but no one says they
have to be. You need to read the source of the page you're trying to log on
to and see what variables actually need to be sent. You can then modify the
post line to send the correct name/value pairs (i.e., fieldname => 'value').

<<<<<<<<<<<<<<,

Matt

Matt thanks for responding to my posting.

I should have explained that I did try to determine the correct variables to
use. I found the following in the source code for the login sheet that I
thought applied to "username" and that is why I used "text" in my code.
<input type=text name="username" size="15" maxlength="35"
AUTOCOMPLETE="off">

And the following that is why I used "password"
<input type="password" name="password" size="15" ONKEYDOWN="return
handleEnterSubmission( this.form , event)" maxlength="35"
AUTOCOMPLETE="off">

And the following that I assume applies to the "button" confused me - but I
made a stab at it. I'm not sure how I show that the button has been pushed.
<input type="image" name="submit" value="Submit"
SRC="/images/login/log_on.gif" border="0">

Also i understand that some secure sites may encript the data going in. How
can I determine if that is required for this site?

I need more help please.

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top