Skip to content

Instantly share code, notes, and snippets.

@mourdok
Created October 22, 2011 02:35
Show Gist options
  • Save mourdok/1305474 to your computer and use it in GitHub Desktop.
Save mourdok/1305474 to your computer and use it in GitHub Desktop.
Resultado da Loteria Federal
clear && perl lwp-simple.pl
#!/usr/local/ActivePerl-5.14/bin/perl
#
# Resultado da Loteria Federal
#
# Libs
use LWP::Simple;
# Main
my $response = get 'http://federal.resultadoloteria.org/';
my @array_response = split /\n/, $response;
foreach (@array_response) {
# Match: número da loteria
if ($_ =~ m/<b style="color: #444444;">LOTERIA FEDERAL (.*)<\/b>/) {
print '==================================' . "\n";
print 'Resultado da Loteria Federal ' . $1 . "\n";
print '==================================' . "\n";
print "\n";
}
# Match: premio, bilhete, valor do premio
if ($_ =~ m/<tr>.*<td class="linhas">(.*)<\/td>.*<td class="meio"><span id="bilhete[0-9]">(.*)<\/span><\/td>.*<td class="premios"><span id="premio[0-9]">(.*)<\/span><\/td>.*<\/tr>/) {
print $1 . ' premio, ';
print 'saiu para o bilhete ' . $2. ', ';
print 'no valor de R$ ' . $3 . '.';
print "\n\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment