annotate PokeScrape.pl @ 0:477258d09353 boosterpack

[svn r1] initial import
author robert
date Sun, 30 Aug 2009 02:19:26 -0400
parents
children d7dd496a4fa6
rev   line source
robert@0 1 use Card;
robert@0 2 use Storable;
robert@0 3
robert@0 4 open POKE, "<all.dat";
robert@0 5
robert@0 6 @allcards = ();
robert@0 7
robert@0 8
robert@0 9 for $line(<POKE>)
robert@0 10 {
robert@0 11 $line =~ m/(<img.*?>).*?(<img.*?>).*?/;
robert@0 12
robert@0 13 $img1 = $1;
robert@0 14 $img3 = $2;
robert@0 15 $line =~ m/(<a.*?<\/a>).*?/;
robert@0 16 $img2 = $1;
robert@0 17
robert@0 18
robert@0 19 #<img src="/cdexdata/images/types/w.gif" alt="Water" title="Water" height="17" width="17" class="t">
robert@0 20
robert@0 21 #<a id="base-set-2-blastoise" href="/scans/base-set/2-blastoise.jpg" title="Blastoise from Base Set (#2)" target="1">Blastoise</a>
robert@0 22
robert@0 23 #<img src="/cdexdata/images/rarities/rare-holo.gif" alt="Rare Holo" title="Rare Holo" width="28" height="16">
robert@0 24
robert@0 25
robert@0 26
robert@0 27
robert@0 28 $img1 =~ m/alt="(.*?)"/;
robert@0 29 $typeTag = $1;
robert@0 30
robert@0 31 $img2 =~ m/\(\#(\d+)\)/;
robert@0 32 $numTag = $1;
robert@0 33 $img2 =~ m/href="(.*?)"/;
robert@0 34 $pix = $1;
robert@0 35 $img2 =~ m/>(.*)</;
robert@0 36 $nameTag = $1;
robert@0 37 $img2 =~ m/from (.*?) \(/;
robert@0 38 $setTag = $1;
robert@0 39
robert@0 40 $img3 =~ m/alt="(.*?)"/;
robert@0 41 $rarityTag = $1;
robert@0 42
robert@0 43
robert@0 44 if ($line =~ m/^<td/)
robert@0 45 {
robert@0 46 print $numTag," ",$nameTag, "\n";
robert@0 47 $tempCard = Card->new();
robert@0 48 $tempCard->addTags($typeTag,$numTag,$nameTag,$setTag,$rarityTag);
robert@0 49 $tempCard->setPix($pix);
robert@0 50 push @allcards,$tempCard;
robert@0 51
robert@0 52
robert@0 53 }
robert@0 54
robert@0 55
robert@0 56
robert@0 57 }
robert@0 58
robert@0 59
robert@0 60 store \@allcards, 'CARD.perl';
robert@0 61
robert@0 62
robert@0 63
robert@0 64 my $refnewstruct = retrieve 'CARD.perl';
robert@0 65
robert@0 66
robert@0 67 print @$refnewstruct[0]->getTags();