root/HTTP-MobileAgent/trunk/bin/makedocomomap

Revision 792 (checked in by miyagawa, 17 years ago)

0.03

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/bin/perl
2 use strict;
3 use Jcode;
4 use LWP::Simple;
5 use Data::Dumper;
6 use HTTP::MobileAgent;
7
8 my $URL = 'http://www.nttdocomo.co.jp/p_s/imode/spec/ryouiki.html';
9
10 do_task(@ARGV);
11
12 sub do_task {
13     my $html = Jcode->new(get($URL))->tr('£°-£¹', '0-9')->euc;
14     $html =~ s/\n+/\n/g;
15     my $re = regexp();
16     my %map;
17     while ($html =~ /$re/gs) {
18         my($model, $width, $height, $color, $depth) = ($1, $2, $3, $4, $5);
19         $map{$model} = {
20             width => $width,
21             height => $height,
22             color => $color eq '¥«¥é¡Œ',
23             depth => $depth,
24         };
25     }
26     output_code(\%map);
27 }
28
29 sub output_code {
30     my $map = shift;
31     $Data::Dumper::Indent = 1;
32     printf <<'TEMPLATE', Data::Dumper->Dump([ $map ], [ qw(DisplayMap) ]);
33 package HTTP::MobileAgent::DoCoMoDisplayMap;
34 # This file is autogenerated by makedocomomap
35 # in HTTP-MobileAgent distribution
36
37 use strict;
38 require Exporter;
39 use base qw(Exporter);
40
41 use vars qw(@EXPORT_OK $DisplayMap);
42 @EXPORT_OK = qw($DisplayMap);
43
44 %s
45
46 1;
47 TEMPLATE
48     ;
49 }
50
51 sub regexp {
52     return <<'RE';
53 <TD><FONT SIZE="2">([A-Z]+\d+\w*)</FONT></TD>
54 <TD><FONT SIZE="2">.*?</FONT></TD>
55 <TD><FONT SIZE="2">.*?</FONT></TD>
56 <TD><FONT SIZE="2">(.*?)¡ß(.*?)</FONT></TD>
57 <TD><FONT SIZE="2">.*?</FONT></TD>
58 <TD><FONT SIZE="2">(Çò¹õ|¥«¥é¡Œ)(\d+)(?:¿§|³¬ÄŽ)</FONT></TD>
59 RE
60     ;
61 }
Note: See TracBrowser for help on using the browser.