X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=scripts%2Fstats.pl;h=321db5bcfbef9db249189b8e39555ee4673cc79f;hb=e71f5648d2823f89024c52b77f9ab04d23a75a2d;hp=706d7c70ff78a8c3ae4cd00adaf4f4a21238ee51;hpb=b52c7c95096825846f53e73de627e6cda01d9bca;p=ndwebbie.git diff --git a/scripts/stats.pl b/scripts/stats.pl index 706d7c7..321db5b 100755 --- a/scripts/stats.pl +++ b/scripts/stats.pl @@ -25,7 +25,8 @@ use warnings; use DBI; use DBD::Pg qw(:pg_types); -use LWP::Simple; +use LWP::Simple qw/get $ua/; +$ua->agent("Stupid user agent check is stupid"); use FindBin; use lib "$FindBin::Bin/../lib"; @@ -38,15 +39,15 @@ $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.php?page=stats"); +my $file = get("http://game.planetarion.com/manual.pl?page=stats"); $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>(\w+)<\/td>(\w+|-)<\/td>(\w+|-)<\/td>(\w+|-)<\/td>(\w+)\D+(\d+)\D+(\d+)\D+(\d+)\D+?(\d+|-)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+\d+\D+\d+.+?(\w+)<\/td>/g){ +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>(\w+)<\/td>(\w+|-)<\/td>(\w+|-)(<\/td>)(\w+)\D+(\d+)\D+(\d+)\D+(\d+)\D+?(\d+|-)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+\d+\D+\d+.+?(\w+)<\/td>/g){ my $dmg = $10; $dmg = 0 if $dmg eq '-'; my $class = $classes{$2}; - $st->execute($1,$class,$3,$4,$5,$6,$7,$8,$9,$dmg,$11,$12,$13,$14,$15) or die $dbh->errstr; - #print "$1,$class,$3,$4,$5,$6,$7,$dmg,$9,$10,$11,$12,$13,$14,$15\n"; + $st->execute($1,$class,$3,$4,'-',$6,$7,$8,$9,$dmg,$11,$12,$13,$14,$15) or die $dbh->errstr; + print "$1,$class,$3,$4,'-',$6,$7,$dmg,$9,$10,$11,$12,$13,$14,$15\n"; } $dbh->commit;