Skip to content

Instantly share code, notes, and snippets.

@Kimtaro
Created June 24, 2009 04:38
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 Kimtaro/135013 to your computer and use it in GitHub Desktop.
Save Kimtaro/135013 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use utf8;
use LWP::UserAgent;
use JSON;
use XML::Simple;
use Data::Dumper;
use Time::HiRes qw(gettimeofday tv_interval);
use URI::Escape qw(uri_escape_utf8);
my $BASE = "http://api.smart.fm";
sub get {
my ($url) = @_;
my $ua = LWP::UserAgent->new;
print "Requesting $url\n";
my $start = [gettimeofday];
my $r = $ua->get($url);
print 'Took '. tv_interval($start, [gettimeofday]) ." seconds\n";
print 'With an X-Runtime of: ' . $r->header('X-Runtime') . "\n";
return $r;
}
my $r = get("$BASE/lists/matching/English.json");
my $json = from_json($r->content);
my @json_ids = sort map {$_->{id}} @{$json};
#print Dumper $json;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment