def get_random_giphy(phrase):
"""Return the URL of a random GIF related to the phrase, if possible"""
with warnings.catch_warnings():
warnings.simplefilter('ignore')
giphy = giphypop.Giphy()
results = giphy.search_list(phrase=phrase, limit=100)
if not results:
raise ValueError('There were no results for that phrase')
return random.choice(results).media_url
评论列表
文章目录