I'm very new to perl+lwp so please excuse mis-statements.

I'm trying to automate a web task.  Here's the steps I do by hand:

Load a main web page
fill in a form with username/pass
submit
click a link on the resulting page
grab some data off the next page

The last page reloads every 30 secons through what appears to be some
php scripting and I need to keep grabbing data off it to dump in a
text file.  I started with WWW::Mechanize which seems to work nicely
but when I submit the form I get an error from the server telling me I
need to enable cookies.  Here's the start of the sample code
(login/pass) have been munged.  Once I get this working I need to
backport it to a more complicated page for school which does the same
thing though.

-------------------------------------------------------------------

#!/usr/bin/perl -w
$|++;

my ($TopURL)="http://www.site.com/index.php";;

use strict;
use diagnostics;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new( autocheck=>1, cookie_jar=>{ file =>
"$ENV{HOME}/.cookies.txt"} );
  $mech->agent_alias( 'Windows IE 6' );
$mech->get( $TopURL ) || die "Can't Connect to $TopURL : $!";


#
my ($UserName)="Foo";
my ($Passwd)="Bar";

my ($tmp, $loop, @foo, $Content, $PHPSessID);

# Log in.
$mech->submit_form(
  form_number => 1,
  fields    => { 'username' => '$UserName', 'password' => '$Passwd'
  }
);
print $mech->content();




--

:wq!
---------------------------------------------------------------------------
Robert L. Harris

DISCLAIMER:
      These are MY OPINIONS             With Dreams To Be A King,
       ALONE.  I speak for              First One Should Be A Man
       no-one else.                       - Manowar


-- 

:wq!
---------------------------------------------------------------------------
Robert L. Harris

DISCLAIMER:
      These are MY OPINIONS             With Dreams To Be A King,
       ALONE.  I speak for              First One Should Be A Man
       no-one else.                       - Manowar

Reply via email to