Last active
August 29, 2015 14:02
-
-
Save psmay/a10e6e9d3c4840e88f6a to your computer and use it in GitHub Desktop.
What it http://hackaday.io/project/695 might look like if I'd written it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use 5.010; | |
use WWW::Mechanize; | |
sub get_description { | |
my $count = shift; | |
my $padded_count = sprintf("%05d", $count); | |
# Set up the description. | |
return qq{ HaD Projects frontpage is a mix of "most popular", "new" and "Recently Updated" posts. Frontpage placement translates into views / follows / skulls / other meaningless ego measurements. Well, if I can't be new or popular, there's a loophole: just make a tweak to the project details, and I'm "recently updated" again! | |
What if I just spent all day playing Nethack and so there aren't any real updates to make? No problem. I;ll just game the system with Perl's WWW::Mechanize to increase a counter every thirty seconds. So far, this page has been updated $padded_count times. | |
An unscrupulous user might use this to artificially drive traffic up on their Kickstarter-listed project. Not me, though, nope, no sirree! Having this project promote itself is just a bit of fun. | |
...Although if you wanted to submit more alarms to my alarm clock while you're here, well, that's certainly your call... | |
http://hackaday.io/project/598-Wake-Me!---Crowdsourced-Alarm-Clock }; | |
} | |
my $agent = WWW::Mechanize->new(); | |
# Log in | |
$agent->get("http://hackaday.io/signin?returnUrl=%2F"); | |
# This form doesn't have a name, but there's only one on the page, so... | |
$agent->field("email", 'kennedy.greg@gmail.com'); | |
$agent->field("password", '*****************************'); | |
$agent->click(); | |
# And the initial counter. | |
my $count = 0; | |
# Ready to start our dastardly deeds. | |
for(;;) { | |
$count++; | |
print "Setting the new count to $count... "; | |
# Go to the project edit page. | |
$agent->get("http://hackaday.io/project/695/edit"); | |
# Update the description. | |
$agent->form_number(0); | |
$agent->field("description", get_description($count)); | |
# Re-publish | |
$agent->click(); | |
say "done!"; | |
# Sleep 30 seconds. | |
sleep(30); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment