Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created November 26, 2015 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/0d47be34a2634cc9958d to your computer and use it in GitHub Desktop.
Save zoffixznet/0d47be34a2634cc9958d to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::UserAgent;
use Data::Dumper;
use 5.020;
use Mojo::DOM;
my $d = Mojo::DOM->new("<div class=\"section even\"><h1>UTC-12</h1><div class=\"cloud scloud w90\"><ul><li id=\"c0\"><a class=\"s1 country multizone bold\" href=\"U.S._Minor_Outlying_Islands\" onmouseout=\"hvr(0)\" onmouseover=\"hvr(0,1)\">Illes Perif\x{e8}riques Menors dels EUA</a>
<ul>
<li><a class=\"s2\" href=\"Baker_Island\">Baker Island</a></li>
<li><a class=\"s2\" href=\"Howland_Island\">Howland Island</a></li>
</ul></li>
</ul></div></div>");
print $d->wrap('<pre></pre>')->to_string;
# __END__
my $dom = Mojo::UserAgent->new->get('http://time.is/time_zones')->res->dom;
my @tzs;
for my $d ( $dom->find('.section')->each ) {
my $tz = { offset => $d->at('h1')->all_text };
use Acme::Dump::And::Dumper;
say "42";
die $d->wrap('<pre></pre>')->to_string;
for my $country_d ( $d->wrap('<zof></zof>')->find('zof > * > div')->each ) {
say "42";
my $name = $country_d->first->all_text;
say $name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment