From 89fd8b4ebb9d3c9fcad03bcdf10ca162df4d2295 Mon Sep 17 00:00:00 2001 From: Vxrtrauter <101264710+Vxrtrauter@users.noreply.github.com> Date: Wed, 4 Mar 2026 20:58:56 +0100 Subject: [PATCH] fix: fix scraping for uztracker posts to support displaying authors properly --- src/core/data/scrapers/uztracker.py | 31 +++++++++++---------------- src/core/interface/gui.py | 2 +- src/core/utils/network/jsonhandler.py | 2 +- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/core/data/scrapers/uztracker.py b/src/core/data/scrapers/uztracker.py index dc111a4..4c1a2de 100644 --- a/src/core/data/scrapers/uztracker.py +++ b/src/core/data/scrapers/uztracker.py @@ -1,10 +1,7 @@ import requests -import threading from bs4 import BeautifulSoup from urllib.parse import urljoin -from core.utils.data.state import state from core.utils.logging.logs import consoleLog -from core.utils.general.wrappers import run_thread def scrape_uztracker(query): base_url="https://uztracker.net/" @@ -16,27 +13,25 @@ def scrape_uztracker(query): response = requests.get(search_url) response.raise_for_status() soup = BeautifulSoup(response.text, 'html.parser') - links = soup.find_all('a', class_="genmed tLink", href=lambda x: x and x.startswith('./viewtopic')) - + links = soup.find_all('tr', class_="tCenter hl-tr", id=lambda x: x and x.startswith('tor_')) for link in links: - if link.b: - title = link.b.text - url = urljoin(base_url, link['href']) + + theme_link = link.find('a', class_="genmed tLink", href=lambda x: x and x.startswith('./viewtopic')) + url = urljoin(base_url, theme_link['href']) + title = theme_link.b.text + author_link = link.find('a', class_="med") + author = author_link.text.strip() if author_link else "Unknown" - author_link = link.find_parent('td').find('a', class_="med ts-text") - author = author_link.text.strip() if author_link else "Unknown" - - posts.append(dict( - title=title, - url=url, - author=author - )) + posts.append(dict( + title=title, + url=url, + author=author + )) return posts except requests.RequestException as e: - if posts: - consoleLog(f"Failed to fetch {search_url}: {e}") + consoleLog(f"Failed to fetch {search_url}: {e}") return None diff --git a/src/core/interface/gui.py b/src/core/interface/gui.py index 6d03f90..8bd4b75 100644 --- a/src/core/interface/gui.py +++ b/src/core/interface/gui.py @@ -157,7 +157,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): header = table.horizontalHeader() header.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch) header.setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed) - header.resizeSection(1, 200) + header.resizeSection(1, 500) header.setStretchLastSection(False) return table diff --git a/src/core/utils/network/jsonhandler.py b/src/core/utils/network/jsonhandler.py index b3e353f..9b205fe 100644 --- a/src/core/utils/network/jsonhandler.py +++ b/src/core/utils/network/jsonhandler.py @@ -25,7 +25,7 @@ def format_data_minimal(data): post_titles = [post["title"] for post in data] post_links = [post["url"] for post in data] - return post_author, post_titles, post_links + return post_author, post_titles, post_links