|
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 |
|---|
| 2 | use strict; |
|---|
| 3 | use warnings; |
|---|
| 4 | use Web::Scraper; |
|---|
| 5 | use URI; |
|---|
| 6 | use YAML; |
|---|
| 7 | use FindBin; |
|---|
| 8 | use File::Spec::Functions; |
|---|
| 9 | use Encode; |
|---|
| 10 | |
|---|
| 11 | my $table_file = shift || catfile($FindBin::Bin, qw/.. dat softbank-table.yaml/); |
|---|
| 12 | my $table = YAML::LoadFile($table_file); |
|---|
| 13 | |
|---|
| 14 | my $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 | |
|---|
| 23 | my $res = $scraper->scrape(URI->new('http://trialgoods.com/emoji/?career=sb&page=all')); |
|---|
| 24 | my %map = map { $_->{unicode} => $_->{name} } @$res; |
|---|
| 25 | |
|---|
| 26 | for my $emoji (@$table) { |
|---|
| 27 | $emoji->{name} = $map{ $emoji->{unicode} }; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | YAML::DumpFile($table_file, $table); |
|---|
| 31 | |
|---|