http://paperlined.org/dev/src/pl/wowtcg/get_hero_validity.pl
#!/usr/bin/perl
# http://www.wowtcgdb.com/cards.aspx "Show Cards By Hero" lists the valid cards for each hero. This
# fetches those in a usable form.
# NOTE: wowtcgdb.com appears to be incomplete! This results in >100% ratios in
# `fetch_regionals_statistics.pl`. The following are a few of the mistakes:
# - Mark of the Wild (HoA 24, a restoration druid card) isn't marked as valid for any deck, though it's valid for Moonshadow
use strict;
use warnings;
use lib '/home/interiot/cpan/lib/';
use LWP::Simple;
use Tie::Storable;
use Storable;
use Data::Dumper;
my $debug = 1;
# on the left is just a quick processing via "vim" from the main URL given above
# on the right is the HoA-$cardnum, entered manually
my %hero_shortnames = (
boris => 1,
dizdemona => 2,
elendril => 3,
gorebelly => 9,
graccus => 4,
grennan => 10,
kayleitha => 11,
litori => 5,
moonshadow => 6,
omedus => 12,
radak => 13,
senzir => 14,
tazo => 15,
thangal => 16,
timmo => 7,
warrax => 8
);
# not included for now because they're not part of the HoA deck
# nimaasus => "
# varanis =>
tie my %wowtcgdb_map => 'Tie::Storable', '.wowtcgdb_map';
open FOUT, ">hero_validity.txt" or die;
foreach my $hero_shortname (keys %hero_shortnames) {
print "----- Processing HERO $hero_shortname -----------\n";
my $html = get "http://www.wowtcgdb.com/hero-$hero_shortname.aspx";
my $hero_card = "AZEROTH " . $hero_shortnames{$hero_shortname} . "/361"; # as above... currently this program handles HoA only
print FOUT "----HERO---- $hero_card\n";
my @wowtcgdb_cardids = ($html =~ /carddetail\.aspx\?id=(\d+)/g);
foreach my $wowtcgdb_cardid (@wowtcgdb_cardids) {
if (!$wowtcgdb_map{$wowtcgdb_cardid}) {
$wowtcgdb_map{$wowtcgdb_cardid} = fetch_wowtcgdb_cardid($wowtcgdb_cardid);
print "Fetching card number $wowtcgdb_cardid: $wowtcgdb_map{$wowtcgdb_cardid}\n";
}
#my $wow_cardid = ($wowtcgdb_map{$wowtcgdb_cardid} ||= fetch_wowtcgdb_cardid($wowtcgdb_cardid));
my $wow_cardid = $wowtcgdb_map{$wowtcgdb_cardid};
print FOUT "$wow_cardid\n" if ($wow_cardid);
}
}
sub fetch_wowtcgdb_cardid {
my $wowtcgdb_cardid = shift;
my $html = get "http://www.wowtcgdb.com/carddetail.aspx?id=$wowtcgdb_cardid";
if ($html =~ m#<b>Number</b>(?:<[^>]*>|\s*)*(\d+)#) {
my $cardnum = $1;
if ($html =~ m#<b>Set</b>(?:<[^>]*>|\s*)*(\w[\w\s]*\w)<#) {
my $set = $1;
if ($set eq 'HoA') {
return "AZEROTH $cardnum/361";
} elsif ($set eq 'OLT') { # Onyxia's Lair Treasure
return "ONYXIA $cardnum/33";
} elsif ($set eq 'TDP') {
return "DARK PORTAL $cardnum/319";
}
# TDP = "Through the dark portal";
}
}
}
Generated by GNU enscript 1.6.4.