Created
March 11, 2009 22:48
-
-
Save electronicbites/77803 to your computer and use it in GitHub Desktop.
get similar artists from the last.fm api
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
#http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=cher&api_key=b25b959554ed76058ac220b7b2e0a026 | |
require 'rubygems' | |
require 'hpricot' | |
require 'net/http' | |
HOST = "ws.audioscrobbler.com" | |
SITE = "/2.0" | |
def get_similar_artists(artist) | |
request = Net::HTTP::Get.new("#{SITE}?method=artist.getsimilar&artist=#{artist}&api_key=b25b959554ed76058ac220b7b2e0a026") | |
Net::HTTP.start("#{HOST}", 80) do |http| | |
(Hpricot(http.request(request).body)/'artist').collect do |artist| | |
(artist/'name').inner_html rescue nil | |
end | |
end | |
end | |
get_similar_artists('cher') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment