Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Created January 14, 2013 04:04
Show Gist options
  • Select an option

  • Save xtetsuji/4527688 to your computer and use it in GitHub Desktop.

Select an option

Save xtetsuji/4527688 to your computer and use it in GitHub Desktop.
キティラーファイブオーディションの中間結果集計スクリプト。2013年1月16日12時まで。投票数は正規の方法で閲覧可能なので、それをゆっくり取得して順位形式として22人を一覧表示するようにした。 see: http://www.with-kitty.com/special/yomecolle_vote/
#!/usr/bin/env perl
# xtetsuji 2013/01/14
# 22人いる
# 最初の猫村いろはは
# http://www.pentatoys.com/vote2/posts/view/7206/?guid=ON
# 最後のは
# http://www.pentatoys.com/vote2/posts/view/7227/?guid=ON
# 特徴ある文字列を正規表現で拾えばよさそう
use strict;
use warnings;
use bytes; # treat utf-8 bytes string
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->env_proxy();
$ua->agent('Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25'); # iOS 6
my @characters;
my $url_format = 'http://www.pentatoys.com/vote2/posts/view/%d/?guid=ON';
for my $num (7206..7227) {
my $res = $ua->get( sprintf $url_format, $num );
if ( $res->is_error ) {
die "ERROR: num=$num msg=" . $res->as_string;
}
my ($name) = $res->content =~ m{\bQ\.(N\d\d_[^\s<]+)};
my ($votes) = $res->content =~ m{\((\d+) votes\)};
push @characters, +{name => $name, votes => $votes};
my $sleep_sec = 5;
sleep $sleep_sec;
warn "sleep $sleep_sec at num=$num\n"; # サイトに負荷をかけないように待つ
}
# 結果表示
print "順位発表\n";
my $rank = 1;
for my $character ( sort { $b->{votes} <=> $a->{votes} } @characters ) {
printf "%2d位: %s (%d票)\n", $rank++, $character->{name}, $character->{votes};
}
__END__
▼2013/01/14 12時時点
順位発表
1位: N03_水無瀬シズク (10323票)
2位: N14_一花 (10207票)
3位: N20_蓬莱 (10047票)
4位: N17_ミウ・クロウフォード (9927票)
5位: N01_猫村いろは (9058票)
6位: N07_聖葉リオ (5920票)
7位: N16_雅 咲久耶 (5640票)
8位: N05_マール・キサラギ (4836票)
9位: N02_蘭道 鈴 (3037票)
10位: N12_橘 みかん (2515票)
11位: N19_霧島 萌 (2459票)
12位: N06_山邑 カリナ (1486票)
13位: N13_桃 (1151票)
14位: N22_ソフィア・K・ブランケット (1044票)
15位: N18_乃木栖 かんな (778票)
16位: N11_真宮・エリー・つばさ (735票)
17位: N04_天風 みさき (687票)
18位: N10_倉嶋タツキ (629票)
19位: N09_北条ミミ (604票)
20位: N08_雪代マイ (595票)
21位: N15_香具楽ノア (338票)
22位: N21_ネオン・ウィー (332票)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment