From 7e5e3033e6f3b52d557c45ccce5e0322e4289a39 Mon Sep 17 00:00:00 2001 From: Vxrtrauter Date: Sat, 18 Oct 2025 01:22:11 +0200 Subject: [PATCH] add scraping logic --- core/data/scrapers/monkrus.py | 18 ++++++++++++++---- core/utils/data/state.py | 5 ++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/core/data/scrapers/monkrus.py b/core/data/scrapers/monkrus.py index ea4bf8c..d3cdff4 100644 --- a/core/data/scrapers/monkrus.py +++ b/core/data/scrapers/monkrus.py @@ -15,12 +15,22 @@ def scrape_monkrus_telegram(): bubbles = soup.find_all("div", class_="tgme_widget_message_bubble") for bubble in bubbles: - post_txt = bubble.find("div", class_="tgme_widget_message_text js-message_text") # this doesnt work - if post_txt.b: - posts.append(Post(text=post_txt.get_text())) + post_txt = bubble.find("div", class_="tgme_widget_message_text js-message_text") + + title = post_txt.b.text + url = bubble.find("a", href=lambda x: x and x.startswith("https://uztracker.net")) - print(post_txt.b.text) + + posts.append(Post( + id = len(posts) + 1, + title = title, + url = url, + author = "m0nkrus" + + )) + + print(posts) diff --git a/core/utils/data/state.py b/core/utils/data/state.py index ebedd07..deb9558 100644 --- a/core/utils/data/state.py +++ b/core/utils/data/state.py @@ -23,4 +23,7 @@ state = AppState(posts=[], post_titles=[], post_urls=[], post_author=[], downloa @dataclass class Post: - text: str + id: int + title: str + url: str + author: str