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