Python GIF API

Asked

Viewed 118 times

0

is my doubt and the following I have this script where I type the name of the gif I want and it returns me several type of url of the size(width,height) of the randomly drawn gif, I wanted it to return me just that:

image_url': 'https://media1.giphy.com/media/3og0IEvmsGQMvKRTEs/giphy.gif', which in case would be the biggest picture he has.

How do I do that?

script taken :https://github.com/Giphy/giphy-python-client/blob/master/docs/DefaultApi.md#gifs_random_get

import time
import giphy_client
from giphy_client.rest import ApiException
from pprint import pprint


api_instance = giphy_client.DefaultApi()
api_key = 'dc6zaTOxFJmzC' 
tag = input('Nome do gif : ') 
rating = 'g' 
fmt = 'json' 

try: 
    # Random Endpoint
    api_response = api_instance.gifs_random_get(api_key, tag=tag, rating=rating, fmt=fmt)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling DefaultApi->gifs_random_get: %s\n" % e)

1 answer

-1


Try this:

...
pprint(api_response.data.image_url)
...
  • It worked Thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.