by Empire of Narnia » Sat Sep 08, 2012 9:53 pm
by Improving Wordiness » Sun Sep 09, 2012 12:22 am
Klaus Devestatorie wrote:I'm a massive tool. ;)
by Ballotonia » Sun Sep 09, 2012 12:55 am
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize;
# Enter your MAIN Nation name here:
my $username = "YOURMAINNATIONNAME";
# Enter names and passwords of your nations here:
my @nations = (
["nation1", "password1"],
["nation2", "password2"],
["nation3", "password3"],
);
# ---------------------------------------------------------------------------------------------
# --- 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
}
}
by Letoilenoir » Sun Nov 11, 2012 5:39 pm
by Unibot III » Sun Nov 11, 2012 6:14 pm
[violet] wrote:I mean this in the best possible way,
but Unibot is not a typical NS player.
Milograd wrote:You're a caring, resolute lunatic
with the best of intentions.
by Ballotonia » Sun Nov 11, 2012 11:56 pm
Unibot III wrote:For Ballo's script use no capitals and use underscores for spaces in regards to nation-names.
Unibot III wrote:Also, be warned, if you have handed out a nation to someone that's on that list and the script is run while your friend is borrowing your nation and using it as a WA Nation while you also have a WA Nation.. it appears as multing to the mods. Speaking from experiencing.
by Unibot III » Mon Nov 12, 2012 1:00 am
Ballotonia wrote:The above script does not have that as a requirement. The name "Unibot III" should work.
[violet] wrote:I mean this in the best possible way,
but Unibot is not a typical NS player.
Milograd wrote:You're a caring, resolute lunatic
with the best of intentions.
by Scoochi2 » Mon Nov 12, 2012 5:08 am
Letoilenoir wrote:Would it be feasible to replicate this in PHP?
by The Blaatschapen » Mon Nov 12, 2012 12:09 pm
Scoochi2 wrote:Letoilenoir wrote:Would it be feasible to replicate this in PHP?
my login script is in pure PHP.
However most servers have a fixed 30 second execution limit.
If you have control, change the value in php.ini to whatever you need (more nations = more time).
If you run PHP locally, you DO have control.
by Scoochi2 » Mon Nov 12, 2012 3:36 pm
The Blaatschapen wrote:Scoochi2 wrote:my login script is in pure PHP.
However most servers have a fixed 30 second execution limit.
If you have control, change the value in php.ini to whatever you need (more nations = more time).
If you run PHP locally, you DO have control.
You can also use set_time_limit(). This has the benefit that you don't need to tweak php.ini by which other scripts might also be affected.
by The Blaatschapen » Wed Feb 06, 2013 4:50 am
Ballotonia wrote:Yes, that is legal.
Here's a legal login script, in Perl:
- Code: Select all
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize;
# Enter your MAIN Nation name here:
my $username = "YOURMAINNATIONNAME";
# Enter names and passwords of your nations here:
my @nations = (
["nation1", "password1"],
["nation2", "password2"],
["nation3", "password3"],
);
# ---------------------------------------------------------------------------------------------
# --- 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
}
}
Make sure to fill in the stuff at the top: main nation name (needed for the UserAgent, so Admin knows who is running which script.) and of course the names and passwords of your nations.
Note that this script uses a 6 second delay between calls, which is important for it to be legal (don't run more than one script at a time though).
Ballotonia
by Svobodny » Wed Feb 06, 2013 4:55 am
by Ballotonia » Wed Feb 06, 2013 8:13 am
The Blaatschapen wrote:Sorry for the revival of this thread, but Ballotonia, can I post an edit on this login script that I made, that will notify the user which puppet has a new telegram?
I just tested it with the new TG system
by Jamie Anumia » Wed Feb 06, 2013 8:19 am
Svobodny wrote:What do you use to execute these scripts? Does it require third party software to be downloaded? If so, from where? I've been looking into doing this for sometime but don't know where to start - never thought to post here!
by The Blaatschapen » Wed Feb 06, 2013 8:21 am
Ballotonia wrote:The Blaatschapen wrote:Sorry for the revival of this thread, but Ballotonia, can I post an edit on this login script that I made, that will notify the user which puppet has a new telegram?
I just tested it with the new TG system
It's ok to post any legal script for others to use as well.
Ballotonia
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize;
# Enter your MAIN Nation name here:
my $username = "YOURMAINNATIONNAME";
# Enter names and passwords of your nations here:
my @nations = (
["nation1", "password1"],
["nation2", "password2"],
["nation3", "password3"],
);
# ---------------------------------------------------------------------------------------------
# --- 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 "\nLOGIN: $nation";
my %envelop = ( nation => $nation, password => $password, logging_in => 1);
while (!defined eval {$mech->post ("http://century.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";
}
}
by QuietDad of TNP » Mon Dec 30, 2019 8:41 pm
by All Wild Things » Tue Dec 31, 2019 3:02 am
QuietDad of TNP wrote:I've been running this script once a month for years without issue. Recently, after running it, I was warned by the admins that it violates the rules by direct HTML calls and not using the API. Looking at it (I'm a programmer for decades),it uses PERL's POST funtion and logs you on thru the web site and not the API. I see that this does violate terms of service,I just have run it monthly for years (scheduled chron job) without an issue supporting my 650+ puppets.
While I fully see the issues and will use one of the other solutions that do a direct API call, I'm just warning everyone while I ran it forever without issue, it doesn't make it right
by The JELLEAIN Republic » Tue Dec 31, 2019 5:24 am
by Cekoviu » Tue Dec 31, 2019 3:03 pm
The JELLEAIN Republic wrote:How would use such a script? Where do you, ... put it ?
by [violet] » Tue Dec 31, 2019 5:31 pm
QuietDad of TNP wrote:I've been running this script once a month for years without issue. Recently, after running it, I was warned by the admins that it violates the rules by direct HTML calls and not using the API.
by QuietDad of TNP » Tue Dec 31, 2019 11:05 pm
by Canyamel » Wed Jan 01, 2020 8:23 am
by [violet] » Wed Jan 01, 2020 5:33 pm
by Random Card Farmer 6 » Tue Sep 19, 2023 1:18 pm
Ballotonia wrote:Yes, that is legal.
Here's a legal login script, in Perl:
- Code: Select all
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize;
# Enter your MAIN Nation name here:
my $username = "YOURMAINNATIONNAME";
# Enter names and passwords of your nations here:
my @nations = (
["nation1", "password1"],
["nation2", "password2"],
["nation3", "password3"],
);
# ---------------------------------------------------------------------------------------------
# --- 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
}
}
Make sure to fill in the stuff at the top: main nation name (needed for the UserAgent, so Admin knows who is running which script.) and of course the names and passwords of your nations.
Note that this script uses a 6 second delay between calls, which is important for it to be legal (don't run more than one script at a time though).
Ballotonia
by Roavin » Tue Sep 19, 2023 2:14 pm
Advertisement
Users browsing this forum: Aethernum, Ammmericaaaa, Baidu [Spider], Bureatania, Chaotic Sparkles, COLORADO 1876, Invictum caeli, Loveable Dogs, New Doggerlund, Osmauri, Picairn, Quebecshire, Telnuhq, The First Grand Reich, Torkeland, Watermelon Cat
Advertisement