Created
May 29, 2013 07:07
-
-
Save letitride/5668465 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use LWP::Simple; | |
use URI::Escape; | |
my $base_url = "http://itunes.apple.com/search?"; | |
my %params; | |
my $name = "宇多田ヒカル"; | |
$params{"country"} = "jp"; | |
$params{"media"} = "music"; | |
$params{"entity"} = "musicTrack"; | |
my $url = make_url( $base_url, \%params, $name ); | |
print get( $url ); | |
sub make_url{ | |
my ( $base_url, $params, $name ) = @_; | |
$params{"term"} = uri_escape( $name ); | |
my $query_string = ""; | |
while (my ( $key, $value ) = each( %{$params} ) ){ | |
$query_string .= sprintf( "&%s=%s", $key, $value ); | |
} | |
return sprintf( "%s%s", $base_url, substr( $query_string, 1 ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment