J
Jim Simpson
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'.
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:
umper;
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);
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:
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);