From 97d613df5814dbc9d57b784a787dfaf1fdd62cef Mon Sep 17 00:00:00 2001 From: t3xhno Date: Tue, 6 Feb 2024 21:17:49 +0100 Subject: [PATCH] Added tasks integration --- functions.py | 3 +++ scraper_functions.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/functions.py b/functions.py index 9884e5d..079b037 100644 --- a/functions.py +++ b/functions.py @@ -23,4 +23,7 @@ def command(msg, rcpt): elif msg.startswith("!wiki"): cmd, query = msg.split(" ", 1) return sf.query_external_website("https://en.wikipedia.org", "/wiki/" + query) + elif msg.startswith("!tasks"): + content = sf.getDmzTasks() + return content diff --git a/scraper_functions.py b/scraper_functions.py index 502f44f..0653206 100644 --- a/scraper_functions.py +++ b/scraper_functions.py @@ -17,3 +17,17 @@ def query_external_website(base_url, query): return "\nTITLE:\n" + title + "\n\nCONTENT:\n" + content.text + "\n\nFULL LINK:\n" + base_url + quote(query) except Exception as e: return e + +def getDmzTasks(): + try: + page = requests.get("https://todo.dmz.rs/") + soup = BeautifulSoup(page.content, "html.parser") + tasks = soup.find_all(class_="task") + result = "\nActive tasks:\n" + for task in tasks: + taskIndex = task.select("div")[0].text + taskTitle = task.select("div")[1].text + result += taskIndex + " " + taskTitle + "\n" + return result + except Exception as e: + return e