added capability to extract the number of channel members when the the string in membersDiv has the word 'subscribers' rather than 'members'.

This commit is contained in:
Tristan Lee
2022-03-29 01:12:07 -05:00
parent de4ebed81f
commit ed829163a0

View File

@@ -177,8 +177,8 @@ class TelegramChannelScraper(snscrape.base.Scraper):
raise snscrape.base.ScraperException(f'Got status code {r.status_code}')
soup = bs4.BeautifulSoup(r.text, 'lxml')
membersDiv = soup.find('div', class_ = 'tgme_page_extra')
if membersDiv.text.endswith(' members'):
kwargs['members'] = int(membersDiv.text[:-8].replace(' ', ''))
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']
r, soup = self._initial_page()