#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; # use HTTP::Cookies; # use HTML::Form; my $urlLog = "http://tennisinsight.com/myTI.php"; my $url = "http://www.tennisinsight.com/match_previews.htm"; my $mech = WWW::Mechanize->new( autocheck => 1, keep_alive => 115, 'Timeout' => '30',); my $cookie_file = "cookies.txt"; my $username = "usr"; #username VALUE my $password = "pss"; #password VALUE my $inputUser = "username"; #username KEY NAME my $inputPassword = "password"; #password KEY NAME $mech->post($urlLog, [ $inputUser => $username, $inputPassword => $password ]); $mech->cookie_jar->save($cookie_file); if (! -s $cookie_file){ $mech->post($urlLog, [ $inputUser => $username, $inputPassword => $password ]); # Save the cookie from this session $mech->cookie_jar->save($cookie_file); } else { $mech->cookie_jar->load($cookie_file); $mech->get("http://www.tennisinsight.com/match_previews.htm"); } # Print to file my $output = $mech->content(); open(my $fh, '>', 'report.html'); print $fh $output; close $fh; print "done\n";