• R/O
  • SSH
  • HTTPS

img0ch: コミット


コミットメタ情報

リビジョン2032 (tree)
日時2010-07-10 23:06:10
作者hikarin

ログメッセージ

* scrapper.pl の screen-mobile-device が更新されていない問題を修正

変更サマリ

差分

--- trunk/maple/test/scripts/scrapper.pl (revision 2031)
+++ trunk/maple/test/scripts/scrapper.pl (revision 2032)
@@ -6,19 +6,20 @@
66 no lib qw(.);
77 use Config::Tiny qw();
88 use IO::String qw();
9+use LWP::Simple;
910 use Net::CIDR::MobileJP::Scraper qw();
1011 use Text::CSV_XS qw();
1112 use Unicode::Japanese qw();
1213
13-my $CIDR_CONFIG_FILE = '../../img0ch/_system/CIDR-mobile-jp.ini';
14-my $SCREEN_CONFIG_FILE = '../../img0ch/_system/screen-mobile-device.ini';
14+my $CIDR_CONFIG_FILE = '../../img0ch/_system/CIDR-mobile-jp.ini';
15+my $SCREEN_CONFIG_FILE = '../../img0ch/_system/screen-mobile-device.ini';
1516
1617 CIDR: {
17- my $cidr = Config::Tiny->new();
18- my $result = Net::CIDR::MobileJP::Scraper->new()->run();
18+ my $cidr = Config::Tiny->new();
19+ my $result = Net::CIDR::MobileJP::Scraper->new()->run();
1920 my @emobile = qw(117.55.1.224/27);
20- my @ibis = qw(219.117.203.9);
21- my @pcsb = qw(123.108.237.240/28 202.253.96.0/28);
21+ my @ibis = qw(219.117.203.9);
22+ my @pcsb = qw(123.108.237.240/28 202.253.96.0/28);
2223 map { $cidr->{pcsb}->{$_} = 1 } sort @pcsb;
2324 map { $cidr->{ibis}->{$_} = 1 } sort @ibis;
2425 map { $cidr->{emobile}->{$_} = 1 } sort @emobile;
@@ -31,26 +32,31 @@
3132 }
3233
3334 SCREEN: {
34- my $lwp = LWP::UserAgent->new();
35- my $res = $lwp->get('http://ke-tai.org/moblist/csv_down.php');
36- my $csv = Text::CSV_XS->new({ binary => 1 });
37- my $io = IO::String->new($res->content());
38- do { <$io> };
35+ mirror( 'http://ke-tai.org/moblist/csv_down.php', 'ktai.csv' );
36+ my $csv = Text::CSV_XS->new( { binary => 1 } )
37+ or die Text::CSV->error_diag();
38+ open my $io, '<', 'ktai.csv' or die $!;
39+ do {<$io>};
3940 my $columns = <$io>;
40- my $unijp = Unicode::Japanese->new();
41- $unijp->set($columns, 'sjis');
41+ my $unijp = Unicode::Japanese->new();
42+ $unijp->set( $columns, 'sjis' );
4243 my $columns_utf8 = $unijp->get();
43- my $screen = Config::Tiny->new();
44- while (my $row = $csv->getline($io)) {
45- $unijp->set($row->[3]);
44+ my $screen = Config::Tiny->new();
45+
46+ while ( my $line = <$io> ) {
47+ $csv->parse($line);
48+ my $row = [ $csv->fields() ];
49+ $unijp->set( $row->[3] );
4650 my $carrier = lc $row->[1];
47- my $device = $unijp->get();
48- my $width = $row->[7];
49- my $height = $row->[8];
50- ($device and $width and $height) or next;
51+ my $device = $unijp->get();
52+ my $width = $row->[7];
53+ my $height = $row->[8];
54+ ( $device and $width and $height ) or next;
5155 $screen->{$carrier} ||= {};
52- if ($device =~ m{/}xms) {
53- map { $screen->{$carrier}->{$_} = join ',', $width, $height } split m{\s*/\s*}, $device;
56+
57+ if ( $device =~ m{/}xms ) {
58+ map { $screen->{$carrier}->{$_} = join ',', $width, $height }
59+ split m{\s*/\s*}, $device;
5460 }
5561 else {
5662 $device =~ s/\A\s*//xms;
@@ -58,6 +64,7 @@
5864 $screen->{$carrier}->{$device} = join ',', $width, $height;
5965 }
6066 }
67+ close $io or die $!;
6168 $screen->write($SCREEN_CONFIG_FILE) or die $SCREEN_CONFIG_FILE, ': ', $!;
6269 }
6370
旧リポジトリブラウザで表示