Created
December 19, 2012 11:34
-
-
Save seouri/4336083 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
#!/usr/bin/perl -w | |
use strict; | |
while (1) { | |
my $r = `curl -s "http://info.nec.go.kr/electioninfo/electionInfo_report.xhtml?electionId=0020121219&requestURI=%2Felectioninfo%2F0020121219%2Fvc%2Fvccp09.jsp&topMenuId=VC&secondMenuId=VCCP&menuId=VCCP09&statementId=VCCP09_%231&electionCode=1&cityCode=0&sggCityCode=0&x=34&y=12"`; | |
my @line = split /\n/, $r; | |
my ($region, $count_p, $perc_p, $count_m, $perc_m, $diff); | |
foreach my $l (@line) { | |
if ($l =~ /<td class="firstTd alignL">(.+)<\/td>/) { | |
$region = $1; | |
$region =~ s/광역시//g; | |
$region =~ s/특별.+$//g; | |
$region =~ s/도$//g; | |
$region =~ s/(청|라|상)//g; | |
print $region, "\t"; | |
} elsif ($l =~ /^\s+<td class=alignR>([\d,]+)<br>\(([\d\.]+)\)<\/td><td class=alignR>([\d,]+)<br>\(([\d\.]+)\)<\/td>/) { | |
print join("\t", sprintf("%10s %4.1f %10s %4.1f %5.1f", $1, $2, $3, $4, $4 - $2)), "\n"; | |
} | |
} | |
print "\n"; | |
sleep 10; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment