root/lang/perl/Encode-JP-Mobile/trunk/tools/softbank-scrape-name.pl

Revision 5227, 0.7 kB (checked in by tokuhirom, 7 months ago)

r5453@skinny (orig r5193): tokuhirom | 2008-01-22 00:30:25 +0900
overwrite the YAML.

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2use strict;
3use warnings;
4use Web::Scraper;
5use URI;
6use YAML;
7use FindBin;
8use File::Spec::Functions;
9use Encode;
10
11my $table_file = shift || catfile($FindBin::Bin, qw/.. dat softbank-table.yaml/);
12my $table = YAML::LoadFile($table_file);
13
14my $scraper = scraper {
15    process '/html/body/div[3]/table/tr',
16        'list[]' => scraper {
17            process '//td[3]', name => 'TEXT';
18            process '//td[5]', unicode => 'TEXT';
19        };
20    result 'list';
21};
22
23my $res = $scraper->scrape(URI->new('http://trialgoods.com/emoji/?career=sb&page=all'));
24my %map = map { $_->{unicode} => $_->{name} } @$res;
25
26for my $emoji (@$table) {
27    $emoji->{name} = $map{ $emoji->{unicode} };
28}
29
30YAML::DumpFile($table_file, $table);
31
Note: See TracBrowser for help on using the browser.