Skip to content

Instantly share code, notes, and snippets.

@Songmu
Created February 22, 2013 05:10
Show Gist options
  • Save Songmu/5010877 to your computer and use it in GitHub Desktop.
Save Songmu/5010877 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.014;
use warnings;
use utf8;
use autodie;
use common::sense;
use LWP::Simple ();
use Web::Query;
use YAML;
my $file = 'emoji4unicode.xml';
unless (-f $file) {
my $content = LWP::Simple::get('http://emoji4unicode.googlecode.com/svn/trunk/data/emoji4unicode.xml');
open my $fh ,'>', $file;
print $fh $content;
}
my $not_in_proposal = sub {
my ($i, $elm) = @_;
my $in_proposal = $elm->attr('in_proposal');
!$in_proposal || $in_proposal ne 'no';
};
my $wq = Web::Query->new_from_html(do{local $/;open my $fh,'<',$file;<$fh>});
my @pictgrams;
$wq->find('category')->each(sub {
my ($i, $elm) = @_;
my $category = $elm->attr('name');
$elm->find('subcategory')->filter($not_in_proposal)->each(sub {
my ($i, $elm) = @_;
my $subcategory = $elm->attr('name');
$elm->find('e')->filter($not_in_proposal)->each(sub {
my ($i, $elm) = @_;
push @pictgrams, {
category => $category,
subcategory => $subcategory,
(map {($_ => $elm->attr($_))} qw/glyphRefID docomo google kddi name text_fallback unicode/)
};
});
});
});
say Dump \@pictgrams;
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment