Skip to content

Instantly share code, notes, and snippets.

@cnaude
Last active Aug 20, 2016
Embed
What would you like to do?
Parse output from http://forums.bukkit.org/members/?page=$i and sort by number of likes.
#!/usr/bin/perl
use strict;
for my $i (1..16420) {
system("wget -O data/bf.$i.html 'http://forums.bukkit.org/members/?page=$i'");
sleep 2;
}
#!/usr/bin/perl
#
use strict;
open (FILE, "zcat data/big.list.gz|") or die $!;
my %hash = {};
while (<FILE>) {
if (/something posted by (.*?) has been 'liked'">Likes Received.*?<dd>(.*?)<\/dd>/) {
$hash{$1} = $2;
$hash{$1} =~ s/,//g;
}
}
close FILE;
sub hashValueDescendingNum {
$hash{$b} <=> $hash{$a};
}
my $count = 1;
foreach my $key (sort hashValueDescendingNum (keys(%hash))) {
print "$count: $hash{$key} $key\n";
$count ++;
}
#!/usr/bin/perl
#
use strict;
open (FILE, "zcat data/big.list.gz|") or die $!;
my %hash = {};
while (<FILE>) {
if (/<dt title="Total messages posted by (.*?)">Messages:<\/dt> <dd>(.*?)<\/dd>/) {
$hash{$1} = $2;
$hash{$1} =~ s/,//g;
}
}
close FILE;
sub hashValueDescendingNum {
$hash{$b} <=> $hash{$a};
}
my $count = 1;
foreach my $key (sort hashValueDescendingNum (keys(%hash))) {
print "$count: $hash{$key} $key\n";
$count ++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment