Skip to content

Instantly share code, notes, and snippets.

Created June 2, 2012 13:13
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 anonymous/2858346 to your computer and use it in GitHub Desktop.
Save anonymous/2858346 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Mojo;
my $ua = Mojo::UserAgent->new;
$ua->max_redirects(5);
my $domain = 'http://api.powerhousemuseum.com';
my $base_url ="$domain/api/v1/category/xml/";
my $api_key = '8fbb61ea34d6f5d';
my $base_rest_url = Mojo::URL->new($base_url)->query({ api_key => $api_key});
my @names = $ua->get($base_rest_url)->res->dom->find('name')
->map(sub { $_->text })->each;
my @num_items =
$ua->get($base_rest_url)->res->dom->find('num_items')
->map( sub { $_->text } )->each;
my @items_uri =
$ua->get($base_rest_url)->res->dom->find('items_uri')
->map( sub { $_->text } )->each;
#
# Template file:
#
print "<table>\n";
for ($i = 0; $i < @names; $i++) {
print "<tr>";
print "<td><a href=\"$domain$items_uri[$i]\">$names[$i]</a></td>";
print "<td>$num_items[$i]</td>";
print "</tr>";
}
print "<table>\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment