Created
October 22, 2011 02:35
-
-
Save mourdok/1305474 to your computer and use it in GitHub Desktop.
Resultado da Loteria Federal
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
clear && perl lwp-simple.pl |
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
#!/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