Last active
July 26, 2019 20:13
-
-
Save jberger/8497caad681c2a69111c99e6bd157042 to your computer and use it in GitHub Desktop.
This file contains 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
use Mojo::Base -strict; | |
use Mojo::URL; | |
use Mojo::UserAgent; | |
my $ua = Mojo::UserAgent->new; | |
my ($id) = @ARGV; | |
my $url = Mojo::URL->new('http://www.j-archive.com/showgame.php')->query(game_id => $id); | |
my $dom = $ua->get($url)->result->dom; | |
$dom->find('.round')->each(sub{ | |
my @cats = $_->find('.category .category_name')->map('text')->each; | |
$_->find('.clue')->each(sub{ | |
my $tile = $_->at('.clue_text'); | |
my ($col, $row) = $tile->{id} =~ /clue_\w+_(\d)_(\d)/; | |
my $text = $tile->text; | |
my ($answer) = $_->at('div[onmouseover]')->{onmouseover} =~ m!(\Q<em class="correct_response">\E.*\Q</em>\E)!; | |
$answer = Mojo::DOM->new($answer)->all_text; | |
say "$cats[$col - 1]: Q: '$text' A: '$answer'"; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment