Compare commits

..

4 Commits

5 changed files with 16 additions and 21 deletions
+5 -10
View File
@@ -1,10 +1,7 @@
import requests import requests
import threading
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from urllib.parse import urljoin from urllib.parse import urljoin
from core.utils.data.state import state
from core.utils.logging.logs import consoleLog from core.utils.logging.logs import consoleLog
from core.utils.general.wrappers import run_thread
def scrape_uztracker(query): def scrape_uztracker(query):
base_url="https://uztracker.net/" base_url="https://uztracker.net/"
@@ -16,14 +13,13 @@ def scrape_uztracker(query):
response = requests.get(search_url) response = requests.get(search_url)
response.raise_for_status() response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser') 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: for link in links:
if link.b:
title = link.b.text
url = urljoin(base_url, link['href'])
author_link = link.find_parent('td').find('a', class_="med ts-text") 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 = author_link.text.strip() if author_link else "Unknown"
posts.append(dict( posts.append(dict(
@@ -35,7 +31,6 @@ def scrape_uztracker(query):
return posts return posts
except requests.RequestException as e: 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 return None
+1 -1
View File
@@ -157,7 +157,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
header = table.horizontalHeader() header = table.horizontalHeader()
header.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch) header.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
header.setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed) header.setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed)
header.resizeSection(1, 200) header.resizeSection(1, 500)
header.setStretchLastSection(False) header.setStretchLastSection(False)
return table return table
+1 -1
View File
@@ -8,7 +8,7 @@ class AppState(QObject):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.posts: List[Dict[str, Any]] = [] self.posts: list[Any] | None = None
self.post_titles: Optional[List] = None self.post_titles: Optional[List] = None
self.post_urls: Optional[List] = None self.post_urls: Optional[List] = None
self.post_author: List[str] = [] self.post_author: List[str] = []