mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
fully impl. monkrus scraper (+ add search logic to scraper)
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
from core.utils.data.state import state
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
|
||||
|
||||
|
||||
def scrape_monkrus_telegram():
|
||||
def scrape_monkrus_telegram(query):
|
||||
telegram_channel = "https://t.me/s/real_monkrus/"
|
||||
posts: list[dict] = []
|
||||
|
||||
@@ -18,12 +17,13 @@ def scrape_monkrus_telegram():
|
||||
title = post_txt.b.text
|
||||
url = bubble.find("a", href=lambda x: x and x.startswith("https://uztracker.net"))
|
||||
|
||||
posts.append(dict(
|
||||
author = "m0nkrus",
|
||||
id = len(posts) + 1,
|
||||
title = title,
|
||||
url = url["href"]
|
||||
))
|
||||
if query.lower() in title.lower():
|
||||
posts.append(dict(
|
||||
author = "m0nkrus",
|
||||
id = len(posts) + 1,
|
||||
title = title,
|
||||
url = url["href"]
|
||||
))
|
||||
|
||||
posts.reverse() # reverse to show most recent posts (bubbles) at top of list
|
||||
return(posts)
|
||||
@@ -139,7 +139,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
toolbar.setLayoutDirection(Qt.RightToLeft)
|
||||
|
||||
self.tracker_list = QComboBox()
|
||||
self.tracker_list.addItems(["rutracker", "uztracker"])
|
||||
self.tracker_list.addItems(["rutracker", "uztracker", "m0nkrus"])
|
||||
self.tracker_list.activated.connect(self.set_tracker)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
from core.data.scrapers.uztracker import scrape_uztracker
|
||||
from core.data.scrapers.rutracker import scrape_rutracker
|
||||
from core.data.scrapers.monkrus import scrape_monkrus_telegram
|
||||
from core.utils.network.jsonhandler import split_data, format_data
|
||||
from core.utils.data.state import state
|
||||
|
||||
@@ -55,4 +55,20 @@ def return_pressed(self):
|
||||
if state.debug:
|
||||
print(f"No response from rutracker")
|
||||
self.softwareList.clear()
|
||||
self.show_empty_results(True)
|
||||
self.show_empty_results(True)
|
||||
|
||||
elif state.tracker == "m0nkrus":
|
||||
state.posts = scrape_monkrus_telegram(search_text)
|
||||
|
||||
if state.posts == []:
|
||||
if state.debug:
|
||||
print(f"No Results for {search_text}")
|
||||
self.softwareList.clear()
|
||||
self.show_empty_results(True)
|
||||
else:
|
||||
state.post_titles, _, state.post_author = format_data(state.posts)
|
||||
self.show_empty_results(False)
|
||||
self.post_author_list.clear()
|
||||
self.post_author_list.addItems(state.post_author)
|
||||
self.softwareList.clear()
|
||||
self.softwareList.addItems(state.post_titles)
|
||||
|
||||
Reference in New Issue
Block a user