Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings;
- use WWW::Mechanize;
- # Enter your MAIN Nation name here:
- my $username = "YOUR NATION HERE";
- # Enter names and passwords of your nations here:
- my @nations = (
- ["Nation1", "Password"],
- ["Nation2", "Password"],
- ["Nation3", "Password"],
- ["Nation4", "Password"],
- ["Nation5", "Password"],
- ["Nation6", "Password"],
- ["Nation7", "Password"],
- ["Nation8", "Password"],
- ["Nation9", "Password"],
- ["Nation10", "Password"],
- ["Nation11", "Password"],
- ["Nation12", "Password"],
- ["Nation13", "Password"],
- ["Nation14", "Password"],
- ["Nation15", "Password"],
- ["Nation16", "Password"],
- );
- #-----------------------------------------------------------------------------------
- # --- Nothing to edit beyond this point ---
- my $delayTime = 6; # pause between fetches
- my $mech = WWW::Mechanize->new ();
- $mech->agent ("Nation:$username ");
- foreach my $loginItem (@nations)
- {
- my $nation = lc($loginItem->[0]);
- $nation =~ s/ /_/g;
- my $password = $loginItem->[1];
- print "LOGIN: $nation \n";
- my %envelop = ( nation => $nation, password => $password, logging_in => 1);
- while (!defined eval {$mech->post ("http://www.nationstates.net", \%envelop)})
- {
- print "Trying again...\n";
- sleep ($delayTime);
- }
- sleep ($delayTime);
- my $pageContent = $mech->content ();
- utf8::decode ($pageContent);
- if (-1 == rindex ($pageContent, "a href=\"nation=$nation\" class=\"STANDOUT\""))
- {
- print "LOGIN FAILED! Halting run...\n";
- last; # jump out of foreach loop
- }
- if (-1 != rindex ($pageContent, "You have <a href=\"page=telegrams\">"))
- {
- print " :has telegrams \n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement