Advertisement
Severisen

Untitled

Sep 22nd, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.74 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use WWW::Mechanize;
  5.  
  6. # Enter your MAIN Nation name here:
  7. my $username = "YOUR NATION HERE";
  8.  
  9. # Enter names and passwords of your nations here:
  10. my @nations = (
  11. ["Nation1", "Password"],
  12. ["Nation2", "Password"],
  13. ["Nation3", "Password"],
  14. ["Nation4", "Password"],
  15. ["Nation5", "Password"],
  16. ["Nation6", "Password"],
  17. ["Nation7", "Password"],
  18. ["Nation8", "Password"],
  19. ["Nation9", "Password"],
  20. ["Nation10", "Password"],
  21. ["Nation11", "Password"],
  22. ["Nation12", "Password"],
  23. ["Nation13", "Password"],
  24. ["Nation14", "Password"],
  25. ["Nation15", "Password"],
  26. ["Nation16", "Password"],
  27.  
  28.  
  29. );
  30.  
  31. #-----------------------------------------------------------------------------------
  32. # --- Nothing to edit beyond this point ---
  33. my $delayTime = 6; # pause between fetches
  34. my $mech = WWW::Mechanize->new ();
  35. $mech->agent ("Nation:$username ");
  36.  
  37. foreach my $loginItem (@nations)
  38. {
  39.     my $nation = lc($loginItem->[0]);
  40.     $nation =~ s/ /_/g;
  41.     my $password = $loginItem->[1];
  42.     print "LOGIN: $nation \n";
  43.     my %envelop = ( nation => $nation, password => $password, logging_in => 1);
  44.     while (!defined eval {$mech->post ("http://www.nationstates.net", \%envelop)})
  45.     {
  46.         print "Trying again...\n";
  47.         sleep ($delayTime);
  48.          }
  49.     sleep ($delayTime);
  50.     my $pageContent = $mech->content ();
  51.     utf8::decode ($pageContent);
  52.     if (-1 == rindex ($pageContent, "a href=\"nation=$nation\" class=\"STANDOUT\""))
  53.          {
  54.             print "LOGIN FAILED! Halting run...\n";
  55.             last; # jump out of foreach loop
  56.             }
  57.     if (-1 != rindex ($pageContent, "You have <a href=\"page=telegrams\">"))
  58.         {
  59.             print " :has telegrams \n";
  60.             }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement