Hi,
Thanks to everyone for their responses.  I am very impressed by how quickly
people responded.  I'm subscribed to the digest format, so I didn't realize
that my complete script didn't get posted until now.  (I think it was a
paste error on my part.)  So, for completeness, in case anyone wanted to see
it, here it is.

Again, thanks for the suggestions. 

Larry Wissink.

This script retrieves the login page.  I pipe this to a file from the
command line:
c:\do_get.pl > befree_login.html

#perl
use strict;
use LWP;
use HTTP::Cookies;
my $browser;


my $webpage;
$webpage = do_GET ('http://affiliates.befree.com/Affiliates/index.jsp');

print $webpage;



sub do_GET {
$browser = LWP::UserAgent->new() unless $browser;
$browser->agent("Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
rv:1.0.2)");
my $cookie_file = "cookie.txt";
$browser->cookie_jar(HTTP::Cookies->new(
        'file' => $cookie_file, 'autosave' => 1
        ));
my @netscape_like_headers = (
 'UserAgent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2)',
 'Accept-Language' => 'en-US',
 'Accept-Charset' => 'iso8859-1,*,utf-8',
 'Accept-Encoding' => 'gzip',
 'Accept' => "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*"
 );
my $resp = $browser->get(@_,@netscape_like_headers);
return ($resp->content, $resp->status_line, $resp->is_success, $resp)
  if wantarray;
return unless $resp->is_success;
return $resp->content;
}


This script is supposed to login to the site using the info from the
previous webpage.  Unfortunately, it returns an error message saying the
page is temporarily unavailable.  I think that means that I haven't got the
cookies or authentication quite right.

#perl -w
#be_free_login.pl

use strict;
my $out_file = "befree_login.html";

use LWP;
use HTTP::Cookies;

my $browser = LWP::UserAgent->new;
$browser->agent("Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
rv:1.0.2)");
my $cookie_file = 'C:\Documents and
[EMAIL PROTECTED]';
$browser->cookie_jar(HTTP::Cookies->new(
        'file' => $cookie_file, 'autosave' => 1
        ));
my @netscape_like_headers = (
 'UserAgent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2)',
 'Accept-Language' => 'en-US',
 'Accept-Charset' => 'iso8859-1,*,utf-8',
 'Accept-Encoding' => 'gzip',
 'Accept' => "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*"
 );

my $response = $browser->post(
 
'http://affiliates.befree.com/Affiliates/login.do;jsessionid=25M6fzYMqVuao0l
mWQV81dAO4JAfEudUHgzqg4n3nwmfzIFWQe9p!1888438520!-1062723984!8001!7002',
  [ 
  "UserAgent" => "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
rv:1.0.2)",
 "Accept-Language" => "en-US",
 "Accept-Charset" => "iso8859-1,*,utf-8",
 "Accept-Encoding" => "gzip",
 "Accept" => "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*",
   "username" => "someone",
   "password" => "***",
   "submit" => "Log On",
   "languageId" => "1"
   ]
 );
   
 die "Error: ", $response->status_line, "\n"
   unless $response->is_success;
   
 open(OUT, ">$out_file") || die "Can not write-open $out_file: $!";
 binmode(OUT);
 print OUT $response->content;
 close(OUT);
 print "Bytes saved: ", -s $out_file, " in $out_file\n";
 
 

Original Message:
Hi,
I'm a Perl newbie in way over my head, but I love a challenge.  
My company needs to download transaction data from a partner's website on a
regular basis.  The data can be retrieved through a form, (entering date
ranges, selecting merchants, etc.), but one must log in to the site first
and must use Netscape 4.0 or IE 5.0 or higher.  I am trying to use LWP and
related Perl modules to emulate a Netscape browser, login to the site and
then fill out the form.
Unfortunately, I just don't know enough about emulating a browser or secure
transactions to do the job.  I am hoping someone out there can point me to
some resources for learning more about these topics.  Most of what I have
been able to do comes from reading "Perl & LWP" by Sean M. Burke (O'Reilly
Press).
I include what I have managed to write, drawn heavily from the Burke book,
for the edification (or amusement) of others.  Again, any insight will be
greatly appreciated.

Sincerely,

Larry Wissink
[EMAIL PROTECTED]

This script retrieves the login page.  I pipe this to a file from the
command line:
c:\do_get.pl > befree_login.html

#perl
use strict;
use LWP;
use HTTP::Cookies;
my $browser;



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to