We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent df302d8 commit 55d8fc3Copy full SHA for 55d8fc3
1 file changed
plugins/animal_gifs.py
@@ -18,12 +18,16 @@
18
def get_gifs(url):
19
soup = get_soup(url)
20
container = soup.find('div', class_="row")
21
- gifs = [urljoin(url, elem["src"]) for elem in container.find_all('img')]
+ gifs = [urljoin(url, elem["data-src"]) for elem in container.find_all('img', {'data-src': True})]
22
return gifs
23
24
25
def get_random_gif(url):
26
- return random.choice(get_gifs(url))
+ gifs = get_gifs(url)
27
+ if not gifs:
28
+ return "No GIFs found"
29
+
30
+ return random.choice(gifs)
31
32
33
@hook.command(autohelp=False)
0 commit comments