Skip to content

Commit 55d8fc3

Browse files
authored
Update animal_gifs.py scraper format (CloudBotIRC#204)
1 parent df302d8 commit 55d8fc3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

plugins/animal_gifs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818
def get_gifs(url):
1919
soup = get_soup(url)
2020
container = soup.find('div', class_="row")
21-
gifs = [urljoin(url, elem["src"]) for elem in container.find_all('img')]
21+
gifs = [urljoin(url, elem["data-src"]) for elem in container.find_all('img', {'data-src': True})]
2222
return gifs
2323

2424

2525
def get_random_gif(url):
26-
return random.choice(get_gifs(url))
26+
gifs = get_gifs(url)
27+
if not gifs:
28+
return "No GIFs found"
29+
30+
return random.choice(gifs)
2731

2832

2933
@hook.command(autohelp=False)

0 commit comments

Comments
 (0)