Created
July 8, 2009 22:37
-
-
Save ussjoin/143262 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Steam.pm 2009-06-26 19:58:32.000000000 -0400 | |
+++ NewSteam.pm 2009-07-08 18:55:12.000000000 -0400 | |
@@ -40,7 +40,9 @@ | |
my $achv_scraper = scraper { | |
process q{div#BG_top h2}, | |
'title' => 'TEXT'; | |
- process q{//div[@class='achievementClosed']}, | |
+ process q{html}, | |
+ 'html' => 'HTML'; | |
+ process q{//div[@class='achieveTxtHolder']}, | |
'achvs[]' => scraper { | |
process 'h3', 'title' => 'TEXT'; | |
process 'h5', 'description' => 'TEXT'; | |
@@ -72,10 +74,25 @@ | |
); | |
next URL if !$items; | |
- my ($title, $achvs) = @$items{qw( title achvs )}; | |
+ my ($title, $html, $achvs) = @$items{qw( title html achvs )}; | |
$title =~ s{ \s* Stats \z }{}xmsi; | |
- for my $item (@$achvs) { | |
+ next URL if ($title =~ /Global Gameplay/i); | |
+ | |
+ # So we have the full source code in $html; we need to count how many achievements are before | |
+ # the critical <br /><br /><br /> line dividing achieved from unachieved. | |
+ | |
+ next URL if ($html !~ /\<br\ \/\>\<br\ \/\>\<br\ \/\>.+/); # If the line isn't there, they don't have any achievements yet. | |
+ | |
+ $html =~ s/\<br\ \/\>\<br\ \/\>\<br\ \/\>.+//; | |
+ my @splitlist = split(/achieveTxtHolder/, $html); | |
+ my $count = scalar @splitlist; | |
+ $count = $count - 2; #This method ends up with one too many, always, and we want the last valid *INDEX* number. | |
+ | |
+ my @achievements = @$achvs; | |
+ $#achievements = $count; # Truncates the array | |
+ | |
+ for my $item (@achievements) { | |
$item->{gametitle} = $title; | |
$item->{ident} = $ident; | |
$item->{gamecode} = $gamecode; | |
@@ -87,7 +104,7 @@ | |
$class->build_results( | |
author => $author, | |
- items => $achvs, | |
+ items => \@achievements, | |
identifier => 'ident,gamecode,title', | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment