### # $Id: hof.pl,v 0.24 2003/06/30 11:58:54 dseg Exp dseg $ # # Written by dseg: <ds26 at mail.goo.ne.jp> # Just a quick hack, don't blame me about this... # # Note: Script charset must be EUC-JP
require 5; use strict; use LWP::Simple;
my $url = 'http://srad.jp/users.pl?uid='; my $max_uid = 29999; my ($html, $name, $subs, $is_author); my (@name, @subs, @uid); my $re_nick = qr<[ a-zA-Z0-9_\$.+!*\'(),-\\]+>; # see http://srad.jp/users.pl?uid=6182 (!!!) my %authors = getListOfAuthors('http://srad.jp/authors.shtml', $re_nick) or die "Something wrong happened\n";
# uid 8796 & 8797 doesn't exist. seems strange, don't know why for my $uid (3..8795, 8798..$max_uid) { $html = get($url . $uid); print "Failed fetching information [user id = $uid]\n" and exit unless defined $html;
print STDERR "Now processing [user id = $uid] ...\n";
# no more users...? $max_uid = $uid-1 and last unless ($name) = $html =~ /($re_nick) \([1-9]\d*\) のユーザ情報/o;
# save all information to .csv open F_CSV, '>hof.csv' or die $!; print F_CSV (join ',', $uid[$_], $name[$_], $subs[$_]), "\n" for 0..$#subs; close F_CSV;
# output html open F_HTML,'>hof.html' or die $!; print F_HTML '<html><head><meta http-equiv="Content-Type" content="text/html; charset=euc-jp">', '<title>Stats of Slashdot.jp submitters</title></head>', '<body>もっとも採用されたタレコミニスト ', (sprintf('(<b>Generated on %04d/%02d/%02d %02d:%02d</b>)<p>', sub {($_[5]+1900, $_[4]+1, $_[3], $_[2], $_[1])}->(localtime))), '<tt>';
my @index = sort { $subs[$b] <=> $subs[$a] or $name[$a] cmp $name[$b] } 0..$#subs; my ($old_subs, $rank, $inner_cnt) = (0, 0, 0);