From 6152af251711b5b255c3a8167f8b1ff72e19ef6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gl=C3=BCpker?= Date: Wed, 1 May 2024 09:52:09 +0200 Subject: Remove telegram and twitter --- telegram.py | 68 ------------------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100755 telegram.py (limited to 'telegram.py') diff --git a/telegram.py b/telegram.py deleted file mode 100755 index d95ce34..0000000 --- a/telegram.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python3 - -from urllib.request import urlopen, Request -from datetime import datetime -from bs4 import BeautifulSoup -import sys - -from rss import _format_date - - -def telegram(channel): - url = "https://t.me/s/" + channel - res = urlopen(Request(url)) - soup = BeautifulSoup(res, features="html.parser") - - # messages = soup.find_all('div', attrs={'class': 'tgme_widget_message_wrap'}) - messages = soup.find_all("div", attrs={"class": "tgme_widget_message_bubble"}) - - for message in messages: - date = message.find("time", attrs={"class": "time"})["datetime"] - html = message.find("div", attrs={"class": "tgme_widget_message_text"}) - # preview = message.find('div', attrs={'class': 'tgme_widget_message_bubble'}) - link = message.find("a", attrs={"class": "tgme_widget_message_date"}) - title = html.text if html else "No text" - description = str(message) # if preview else '?' - link = link["href"] - yield title, description, link, date - - -def main(channel): - url = "https://t.me/s/" + channel - - print( - """ - - - Telegram: """ - + channel - + """ - """ - + url - + """ - The latest entries of the telegram channel of """ - + channel - + """ - """ - + _format_date(datetime.now()) - + """""" - ) - - for title, description, link, date in telegram(channel): - print(" ") - print(" <![CDATA[" + title + "]]>") - print(" " + link + "") - print(" ") - print(" " + date + "") - # print(' ') - print(" ") - - print(" ") - print("") - - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage:", sys.argv[0], "") - sys.exit(1) - main(sys.argv[1]) -- cgit v1.2.3