Skip to content

Instantly share code, notes, and snippets.

@keedi
Created December 19, 2012 12:01
Show Gist options
  • Save keedi/4336200 to your computer and use it in GitHub Desktop.
Save keedi/4336200 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.010;
use utf8;
use strict;
use warnings;
use Text::Trim;
use Try::Tiny;
use Web::Query;
binmode STDIN, ':utf8';
binmode STDOUT, ':utf8';
my $url = '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=28&y=9';
while (1) {
say " 박근혜 문재인 개표율 지역";
try {
wq($url)
->find('div.searchResult div.cont_table table#table01.table01 tbody tr')
->each(sub{
my $i = shift;
return if $i == 0;
printf(
"%20s %20s %10s %s\n",
trim($_->find('td:nth-child(4)')->first->text),
trim($_->find('td:nth-child(5)')->first->text),
trim($_->find('td:nth-child(13)')->first->text),
trim($_->find('td:nth-child(1)')->first->text),
);
});
};
sleep 10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment