-1

I'm trying to get url from object data, but it isn't right. This program has stopped on line 4. Code is under.

My code:

    import requests

    gifs = str(requests.get("https://api.giphy.com/v1/gifs/random? 
    api_key=APIKEY"))
    dump = json.dumps(gifs)
    json.loads(dump['data']['url'])

1 Answers1

0

Your description is not clear enough. You expect to read a json and select a field that brings you something? I recommend you check this section of requests quickstart guide this i suspect you want to read the data to json and extract from some fields. Maybe something like this might help:

r = requests.get('http://whatever.com')  
url = r.json()['url']