CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Perl script to Login into a website and verify number of problems solved

 



hydpm
User

Mar 3, 2010, 2:31 AM

Post #1 of 2 (1616 views)
Perl script to Login into a website and verify number of problems solved Can't Post

Hi,

I'm trying to write a perl script to loginto a website and find the number of problems solved. After login into web site , we will find a string "0 out of 280" it means 0 problems solved .

i need to capture the whatever the number of problems solved.?

Perl test that logs on 'http://projecteuler.net' using a specific username [wingsof5r] and password[test123], and verify that the number of
problem solved reported on 'http://projecteuler.net/index.php?section=problems' are equal to a certain, pre-determined, value.

Using any module will be fine and it will be fine if it produces TAP output.

Please help me.


hydpm
User

Mar 3, 2010, 5:39 AM

Post #2 of 2 (1607 views)
Re: [wingsof5r] Perl script to Login into a website and verify number of problems solved [In reply to] Can't Post

Hi ,
I got a quick and dirty script. But i'm looking for reusable script which is modular for doing the same.

Here is mine .
=========
#!/usr/bin/perl
use strict;
use WWW::Mechanize;
use LWP::Debug qw(+);

my $url = "http://projecteuler.net/index.php?section=login";
my $username = "wingsof5r";
my $password = "test123";

my $mech = WWW::Mechanize->new();
$mech->get($url);
$mech->form_name('form');
$mech->field(username => $username);
$mech->field(password => $password);
$mech->click();

my $problems_link = $mech->follow_link( url_regex => qr/(?i:Problems)/i );

if(!defined($problems_link)) {

print "Not found the Problem Link\n";
}

my $problems_solved = $mech->content;

my $number_of_solved = undef;
#print $problems_solved;

if( $problems_solved=~/(\d+) out of \d+/ )
{
$number_of_solved = $1;
}

print "The no of solved :$number_of_solved\n";

my $expected = 60;

if($number_of_solved == $expected) {
print " First division";
}
else {
print "Not a First Division\n";
}
============================

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives