use strict; use Spreadsheet::WriteExcel; use WWW::Mechanize; # Create a new instance of Mechanize my $bot = WWW::Mechanize->new(); $bot->agent_alias( 'Windows Mozilla' ); # Connect to the login page my $response = $bot->get( 'https://anyURLwithCredentials.com' ); # Get the login form. You might need to change the number. $bot->form_number(3); # Enter the login credentials. $bot->field( username => 'username' ); $bot->field( password => 'password' ); $response = $bot->click(); my $outfile = "out.txt"; open(OUTFILE, ">$outfile"); print OUTFILE $response->decoded_content; close(OUTFILE); open(FILE,$outfile); my @releasesAU; my @releasesAU3G; while () { chomp; my $lineDATA = $_; if(index($lineDATA, "H") != -1){ if( $lineDATA =~ /">([_+\w]*)<\/a>/){ print $1, "\n"; push(@releasesAU3G,$1); } } if(index($lineDATA, "H+") != -1){ if( $lineDATA =~ /">([_+\w]*)<\/a>/){ print $1, "\n"; push(@releasesAU,$1); } } } close(FILE); my $row = 0; my $col=0; my $workbook = Spreadsheet::WriteExcel->new("test.xls"); my $worksheet = $workbook->add_worksheet(); $worksheet->write($row, $col, "Releases H"); $worksheet->write($row, $col+1, "Releases H+"); $row=2; foreach my $SOP (@releasesAU){ $worksheet->write($row, $col, $SOP); $row = $row+1; } $row =2; foreach my $SOP (@releasesAU3G){ $worksheet->write($row, $col+1, $SOP); $row = $row+1; } $workbook->close();