Hi, I've been playing around with the following script as I would like
to access data on a website that I need to log into first.

As you can see I'm attempting to login into the main page and then
check the contents of the same page for a particular piece of data
("Your Home" in this example).

It seems that the servers webpages are generated in PHP so I'm not
sure if this is causing the issue?

I would be appreicate some advice.

Thanks in advance.

---

#!c:\\perl\\bin
use strict;

use WWW::Mechanize;
use HTTP::Cookies;
#use LWP::Debug qw(+);
use LWP::Simple;
use Data::Dumper;

my $url = "http://www.piratequest.net/index.php";;
my $username = "username";
my $password = "password";
my $mech = WWW::Mechanize->new( autocheck => 1 );
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);

#$mech->submit_form(
#        form_number => 1,
#        fields => { username => $username, password => $password }
#);
#die unless ($mech->success);

$mech->form_number('1');
$mech->field("username", $username);
$mech->field("password", $password);
$mech->submit();
die unless ($mech->success);

#print Dumper($mech);

my $content = get $url;
die "Couldn't get $url" unless defined $content;

# Go do things with $content

if($content =~ m/Your Home/i) {
    print "Sucess!!!\n";
} else {
    print "Failure again.\n";
}

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to