I'm trying to write a script that will log me into a page and click a
link.  I've got the logic down but it's been complaining about
cookies.  Using LWP::Debug I'm getting this:


LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking .studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: GET http://www.studiotraffic.com/index.php
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 558 bytes
LWP::Protocol::collect: read 1872 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 2896 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 1925 bytes
HTTP::Cookies::extract_cookies: Set cookie PHPSESSID =>
35db73c36b129dd2f9e5e0b6003a2d41
LWP::UserAgent::request: Simple response: OK
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header:  - checking cookie
PHPSESSID=35db73c36b129dd2f9e5e0b6003a2d41
HTTP::Cookies::add_cookie_header:    it's a match
HTTP::Cookies::add_cookie_header: Checking .studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: POST http://www.studiotraffic.com/checkuser.php
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 2 bytes
LWP::UserAgent::request: Simple response: Found
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header:  - checking cookie
PHPSESSID=35db73c36b129dd2f9e5e0b6003a2d41
HTTP::Cookies::add_cookie_header:    it's a match
HTTP::Cookies::add_cookie_header: Checking .studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking studiotraffic.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: GET
http://www.studiotraffic.com/login.php?invalid=1
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 554 bytes
LWP::Protocol::collect: read 1872 bytes
LWP::Protocol::collect: read 1872 bytes
LWP::Protocol::collect: read 1448 bytes
LWP::Protocol::collect: read 2936 bytes
LWP::Protocol::collect: read 1017 bytes
LWP::Protocol::collect: read 384 bytes
LWP::Protocol::collect: read 2456 bytes
HTTP::Cookies::extract_cookies: Set cookie Cusername => deleted
LWP::UserAgent::request: Simple response: OK

The script is VERY simple at this point:

#!/usr/bin/perl -w

my ($TopURL)="http://www.website.com/index.php";;
use WWW::Mechanize;
use LWP::Debug qw(+);
my $mech = WWW::Mechanize->new( );

$mech->get( $TopURL ) || die "Can't Connect to $TopURL : $!";

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


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



Anyone have any ideas?  I've tried a couple things such as:
use HTTP::Cookies;
my $mech = WWW::Mechanize->new( autocheck=>1, cookie_jar=>{ file =>
"$ENV{HOME}/.cookies.txt"} );
$mech->cookie_jar(HTTP::Cookies->new());

No noticable difference.

Any ideas?
  Robert
-- 

: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