Skip to content

Instantly share code, notes, and snippets.

@yappo
Created June 3, 2015 03:50
Show Gist options
  • Save yappo/4ae5c7289472ef9a38b6 to your computer and use it in GitHub Desktop.
Save yappo/4ae5c7289472ef9a38b6 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Furl;
my $furl = Furl->new( agent => 'Moznion/1.0' );
my $wait = 3;
my %last_vote_counts;
while (1) {
my $res = $furl->get('http://doraperson2015.yapcasia.org/');
my $data = $res->content;
my %current;
my %vote_counts;
while ($data =~ m{<dl>.+?<a href="(.+?)">.+?<em>(\d+)</em>}gsm) {
my($path, $count) = ($1, $2);
$current{$path} = $count - ($last_vote_counts{$path} // 0);
$vote_counts{$path} = $2;
}
%last_vote_counts = %vote_counts;
for my $path (sort { $current{$b} <=> $current{$a} } keys %current) {
printf "%12d/QPS http://doraperson2015.yapcasia.org%s\n", int($current{$path} / $wait), $path;
}
print "\n\n-------------------------------------------------\n\n";
sleep $wait;
}
@yappo
Copy link
Author

yappo commented Jun 4, 2015

@yappo test
@tokuhirom test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment