#!/usr/bin/perl -w use lib "C:/Program Files/Perl Express/Scripts"; use WWW::Mechanize; use LWP::Simple; package ClanBot; #Takes a username and a password, creates a Mechanize object #and uses the Mechanize object to log in to KOL. It returns the Mechanize #object #if login was successful, otherwise it diplays "Wait 60 seconds" and dies. #This sub works with either WWW::Mechanize or WWW::IE::Mechanize sub login { my(@login) = @_; my $mech = WWW::Mechanize->new(); $mech->get( "http://www5.kingdomofloathing.com" ); $mech->submit_form( form_number => 1, fields => { loginname => $login[0], password => $login[1], } ); $url = $mech->uri(); if($url =~ m/game.php/i) { return $mech; } else { print "Wait 60 seconds"; die; } return 0; } #Takes a reference to a mech object, calls back until it is at #game.php, then navigates links to the clan_detailedroster.php #This works with WWW::Mechanize, but whether I'm following links or using #->get(url) with Win32::IE::Mechanize it always refreshes to game.php #immediately sub toroster { $page = $_[0]; $url = $$page->uri(); while(!($$page->uri() =~ m/game.php/)) { $$page->back(); } $$page->follow_link(n=>1); $$page->follow_link(n=>7); $$page->follow_link(n=>7); $$page->follow_link(n=>3); return 1; }