#### use warnings; use HTML::Tree; use LWP::Simple; use WWW::Mechanize; use HTTP::Request::Common; use Data::Dumper; my $username = "user"; my $password = "pass"; my $site_url = 'http://www.tennisinsight.com/myTI.php'; my $mech = WWW::Mechanize->new( autocheck => 1 ); # print $mech->content; my $response = $mech->post($site_url , [ 'username' => $username, 'password' => $password, ]) ; my $cookie_jar = HTTP::Cookies->new; $cookie_jar->extract_cookies( $response ); print $cookie_jar; #### #!/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";