X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=scripts%2Fstats.pl;h=d69d42cb6189c534c3c1844b1e4ef0b97538899a;hb=HEAD;hp=bcac7fe8f81274b2d182b71b677db8728e64b436;hpb=8ce23c2d82afd4382c05a8bdc81e850a1fb16346;p=ndwebbie.git diff --git a/scripts/stats.pl b/scripts/stats.pl index bcac7fe..ee12e93 100755 --- a/scripts/stats.pl +++ b/scripts/stats.pl @@ -24,28 +24,40 @@ use strict; use warnings; use DBI; use DBD::Pg qw(:pg_types); +use Data::Dumper; -use LWP::Simple; -use lib qw{/var/www/ndawn/}; -use ND::DB; +use LWP::Simple qw/get $ua/; +$ua->agent("Stupid user agent check is stupid"); -our $dbh = ND::DB::DB(); +use FindBin; +use lib "$FindBin::Bin/../lib"; -$dbh->do("SET CLIENT_ENCODING TO 'LATIN1';"); +use ND::DB; +use NDWeb::Stats; -my %classes = (Fighter => 'Fi', Corvette => 'Co', Frigate => 'Fr', Destroyer => 'De', Cruiser => 'Cr', Battleship => 'Bs'); +our $dbh = ND::DB::DB(); -my $file = get("http://game.planetarion.com/manual.php?page=stats"); +my $file = get("http://game.planetarion.com/manual.pl?action=statsxml"); $dbh->begin_work; -my $st = $dbh->prepare(q{INSERT INTO ship_stats (name,"class",t1,t2,t3,"type",init,guns,armor,damage,eres,metal,crystal,eonium,race) VALUES(?,?,NULLIF(?,'-'),NULLIF(?,'-'),NULLIF(?,'-'),?,?,?,?,?,?,?,?,?,?)}); -while ($file =~ /((?:\w| )+)<\/td>