Skip to content

Instantly share code, notes, and snippets.

@ilyasahsan123
Created November 22, 2017 03:14
Show Gist options
  • Save ilyasahsan123/083db981d957462e22d7e8e7a535bf82 to your computer and use it in GitHub Desktop.
Save ilyasahsan123/083db981d957462e22d7e8e7a535bf82 to your computer and use it in GitHub Desktop.
python get value from rest api
import request
import json
# get top artist with last.fm api
# search on google last.fm api please
def get_artist_name(URL):
data = request.get(URL).text
data = json.loads(data)
top_artist = data["topartists"]["artist"][0]["name"]
pass
if __name__ == "__main__":
api_key = ""
URL = "http://ws.audioscrobbler.com/2.0/?method=geo.gettopartists&country=spain&api_key=" + api_key +"&format=json"
get_artist_name(URL)
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment