X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=scripts%2Fstats.pl;h=ee12e933e2a4af0968638762127ce1086c887529;hb=82c8844f01d81e70b789cdbd455bedc4b2f94c87;hp=bcac7fe8f81274b2d182b71b677db8728e64b436;hpb=f2c438684b7835e8c2033999fcc020d9352afca8;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>