From fb8d73ac95011b7ad848a6048d3eed1880e80f21 Mon Sep 17 00:00:00 2001 From: Tristan Lee Date: Tue, 29 Mar 2022 13:15:53 -0500 Subject: [PATCH] handled case where channel has no profile image --- snscrape/modules/telegram.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/snscrape/modules/telegram.py b/snscrape/modules/telegram.py index a65671c..399ce95 100644 --- a/snscrape/modules/telegram.py +++ b/snscrape/modules/telegram.py @@ -179,7 +179,11 @@ class TelegramChannelScraper(snscrape.base.Scraper): membersDiv = soup.find('div', class_ = 'tgme_page_extra') if membersDiv.text.endswith((' members', ' subscribers')): kwargs['members'] = int(''.join(membersDiv.text.split(' ')[:-1])) - kwargs['photo'] = soup.find('img', class_ = 'tgme_page_photo_image').attrs['src'] + photoImg = soup.find('img', class_ = 'tgme_page_photo_image') + if photoImg is not None: + kwargs['photo'] = photoImg.attrs['src'] + else: + kwargs['photo'] = None r, soup = self._initial_page() if '/s/' not in r.url: # Redirect on channels without public posts