from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout,QLabel, QLineEdit, QPushButton, QCheckBox, QMessageBox, QGridLayout from concurrent.futures import ThreadPoolExecutor from PyQt5.QtCore import Qt, QThread, pyqtSignal from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from bs4 import BeautifulSoup import sqlite3 import sys BLANK_PAGE_URL = "" class SearchThread(QThread): search_finished = pyqtSignal() def __init__(self, selected_webpages, search_term, parent=None): super(SearchThread, self).__init__(parent) self.selected_webpages = selected_webpages self.search_term = search_term self.error_message = None self.driver = webdriver.Chrome() def run(self): try: for webseite in self.selected_webpages: self.start_search_on_webseite(webseite) except Exception as e: self.error_message = f"Fehler bei der Suche: {e}" finally: self.search_finished.emit() def search_for_website(self,webseite): search_functions = { "Reichelt": self.suche_auf_reichelt, "Conrad": self.suche_auf_conrad, "Kosatec": self.suche_auf_kosatec, "Hornbach": self.suche_auf_hornbach, "Esska": self.suche_auf_esska, "Contorion": self.suche_auf_contorion, "Gastroteile Shop": self.suche_auf_gastroteileshop, "TiroLED": self.suche_auf_tiroled, "Megabad": self.suche_auf_megabad, "Baubeschlagshop": self.suche_auf_baubeschlag, "IPS": self.suche_auf_ips_shop, "Brewes": self.suche_auf_brewes, "Delker": self.suche_auf_delker, "Knauss": self.suche_auf_knauss, "schildershop24": self.suche_auf_schildershop24, "Häfele": self.suche_auf_haefele, "Esmeyer": self.suche_auf_esmeyer, "Papstar": self.suche_auf_papstar, "Pacovis": self.suche_auf_pacovis, "Lusini": self.suche_auf_lusini, "Hygi": self.suche_auf_hygi, "Tischwelt": self.suche_auf_tischwelt, "Schafferer": self.suche_auf_schafferer, "Gastronomie Kaufhaus": self.suche_auf_gastronomie_kaufhaus, "Arbeitsplatzmatten Profi": self.suche_auf_arbeitsplatzmattenprofi, "Skiltex": self.suche_auf_skiltex, "Franz-Mensch": self.suche_auf_franzmensch, "Frank-Flechtwaren": self.suche_auf_frankflechtwaren, "ARA": self.suche_auf_ara_arbeitsschutz, "VKF-Renzel": self.suche_auf_vkf_renzel, "Börner": self.suche_auf_boerner, "GGM-Gastro": self.suche_auf_ggmgastro, "Böttcher": self.suche_auf_boettcher, "Büroshop24": self.suche_auf_bueroshop24, "Buchhandlung am Markt": self.suche_buchhandlung_am_markt, "Label-Ident": self.suche_auf_labelident, "Transpak": self.suche_auf_transpak, "PML": self.suche_auf_pml, "DM-Folien": self.suche_auf_dmfolien, "Proficleanshop": self.suche_auf_proficleanshop, "Siepmann": self.suche_auf_siepmann, "FK-Söhnchen": self.suche_auf_fksoehnchen, "Wahl-Agar": self.suche_auf_wahl_agrar, "TVV-Verpackungen": self.suche_auf_tvv, "Eierschachteln.de": self.suche_auf_eierschachteln, "KOX": self.suche_auf_kox, "Reinigungsberater.de": self.suche_auf_reinigungsberater, "VBS-Hobby": self.suche_auf_vbshobby, "Ökonomed": self.suche_auf_oekonomed, "Rossmann": self.suche_auf_rossmann, "Betzold": self.suche_auf_betzold, } search_function = search_functions.get(webseite) if search_function: search_function() else: print(f"Keine Suchfunktion für die Webseite '{webseite}' gefunden.") def start_search_on_webseite(self, webseite): try: self.driver.execute_script(f"window.open('{BLANK_PAGE_URL}', '_blank');") self.driver.switch_to.window(self.driver.window_handles[-1]) self.search_for_website(webseite) except Exception as e: print(f"Fehler bei der Suche auf {webseite}: {e}") def suche_auf_haefele(self): # URL für die Suche generieren search_url = 'https://www.haefele.de/' # Webseite aufrufen und auf das vollständige Laden warten self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "inputSearchTerm"))) # Suchbegriff eingeben und Suche starten search_box = self.driver.find_element(By.ID, "inputSearchTerm") search_box.clear() search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_auf_brewes(self): search_url = f'https://www.brewes.de/catalogsearch/result?q={self.search_term}' self.driver.get(search_url) def suche_auf_conrad(self): search_url = f'https://www.conrad.de/search.html?search={self.search_term}' self.driver.get(search_url) # Suchbegriff eingeben search_box = self.driver.find_element(By.ID, "header-search") search_box.clear() # Falls vorheriger Text vorhanden ist search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_auf_contorion(self): search_url = f'https://www.contorion.de/suche?q={self.search_term}' # Webseite aufrufen und auf das vollständige Laden warten self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "search-input"))) # Suchbegriff eingeben search_box = self.driver.find_element(By.ID, "search-input") search_box.clear() # Falls vorheriger Text vorhanden ist search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_auf_reichelt(self): search_url = f'https://www.reichelt.de/index.html?ACTION=446&LA=446&nbc=1&SEARCH={self.search_term}' self.driver.get(search_url) WebDriverWait(self.driver, 60).until(EC.presence_of_element_located((By.ID, "searchbutton"))) # Suchbegriff eingeben und Suche starten search_box = self.driver.find_element(By.ID, "quicksearch_new") search_box.clear() # Falls vorheriger Text vorhanden ist search_box.send_keys(self.search_term) # Formular abschicken search_button = self.driver.find_element(By.ID, "searchbutton") search_button.click() def suche_auf_kosatec(self): search_url = f'https://shop.kosatec.de/search?search={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.ID, "CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll") cookie_button.click() def suche_auf_hornbach(self): search_url = f'https://www.hornbach.de/s/{self.search_term}' self.driver.get(search_url) def suche_auf_esska(self): search_url = f'https://www.esska.de/shop/search/{self.search_term}' self.driver.get(search_url) def suche_auf_gastroteileshop(self): search_url = f'https://www.gastroteileshop.de/?s={self.search_term}' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "search-input"))) cookie_button = self.driver.find_element(By.CLASS_NAME, "btn.btn-primary.btn-block.btn-appearance") cookie_button.click() # Suchbegriff eingeben und Suche starten search_box = self.driver.find_element(By.CLASS_NAME, "search-input") search_box.clear() # Falls vorheriger Text vorhanden ist search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_auf_tiroled(self): search_url = f'https://www.tiroled.com/de/search?search={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "cookie-consent-accept-only-functional-button.btn.btn-primary.cookie-consent-button-margin") cookie_button.click() def suche_auf_megabad(self): search_url = f'https://www.megabad.com/search/?query=sdyc/#/q/{self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CSS_SELECTOR, ".cmpboxbtn.cmpboxbtnyes.cmptxt_btn_yes") cookie_button.click() def suche_auf_baubeschlag(self): search_url = f'https://www.baubeschlagshop.de/fts.php?criteria={self.search_term}' self.driver.get(search_url) def suche_auf_ips_shop(self): search_url = f'https://www.ips-kts.com/de/suche?query={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "btn.btn-primary.btn-red.user-type--business") cookie_button.click() def suche_auf_delker(self): search_url = f'https://www.delker2business.com/nwsearch/execute?query={self.search_term}' self.driver.get(search_url) def suche_auf_knauss(self): search_url = f'https://knauss.info/dksearch?sSearch={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "cookie-permission--decline-button.btn.is--large.is--center") cookie_button.click() def suche_auf_schildershop24(self): search_url = f'https://www.schildershop24.de/?action=Query&-query.&query.stichwort=r{self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "btn.btn-primary.button.set-disabled") cookie_button.click() def suche_auf_esmeyer(self): search_url = f'https://www.esmeyer-shop.de/search?search={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "cookie-permission-button.js-cookie-permission-button") cookie_button.click() def suche_auf_papstar(self): search_url = 'https://www.papstar-shop.de/' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "search"))) # Suchbegriff eingeben und Suche starten search_box = self.driver.find_element(By.ID, "search") search_box.clear() # Falls vorheriger Text vorhanden ist search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_auf_pacovis(self): search_url = f'https://www.pacovis.com/de-de/suche/1/search={self.search_term}' self.driver.get(search_url) def suche_auf_lusini(self): search_url = f'https://www.lusini.com/de-de/search/#q={self.search_term}' self.driver.get(search_url) def suche_auf_hygi(self): search_url = 'https://www.hygi.de/' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "qbox"))) cookie_button = self.driver.find_element(By.CLASS_NAME, "btn.btn-light.text-nowrap.btn-block.mb-2") cookie_button.click() # Suchbegriff eingeben und Suche starten search_box = self.driver.find_element(By.ID, "qbox") search_box.clear() # Falls vorheriger Text vorhanden ist search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_auf_tischwelt(self): search_url = f'https://www.tischwelt.de/shop/Suche/?q={self.search_term}&search=Suchen' self.driver.get(search_url) def suche_auf_schafferer(self): search_url = f'https://www.schafferer.de/gastro/Artikel-Suche/?q={self.search_term}' self.driver.get(search_url) def suche_auf_gastronomie_kaufhaus(self): search_url = 'https://www.gastronomie-kaufhaus.de/' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "searchParam"))) # Suchbegriff eingeben und Suche starten search_box = self.driver.find_element(By.ID, "searchParam") search_box.clear() # Falls vorheriger Text vorhanden ist search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_auf_arbeitsplatzmattenprofi(self): search_url = f'https://arbeitsplatzmatten-profi.com/?s={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.ID, "CookieBoxSaveButton") cookie_button.click() def suche_auf_skiltex(self): search_url = 'https://www.skiltex.de/shop/frontpage.html' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "SearchField_SearchPage"))) cookie_button = self.driver.find_element(By.CLASS_NAME, "coi-banner__accept") cookie_button.click() # Auf die Suchleiste klicken search_box = self.driver.find_element(By.CLASS_NAME, "SearchField_SearchPage") search_box.click() search_box.clear() search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.CLASS_NAME, "popuptype.fancybox-content"))) kunde = self.driver.find_element(By.CLASS_NAME, "popuptype_knap_erhverv.moms_off") kunde.click() def suche_auf_franzmensch(self): search_url = f'https://www.franz-mensch.de/search?search={self.search_term}' self.driver.get(search_url) def suche_auf_frankflechtwaren(self): search_url = f'https://www.frank-flechtwaren.de/suchergebnisse/?query={self.search_term}' self.driver.get(search_url) def suche_auf_ara_arbeitsschutz(self): search_url = f'https://ara-arbeitsschutz.de/navi.php?qs={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "cmpboxbtn.cmpboxbtnno.cmptxt_btn_no") cookie_button.click() def suche_auf_vkf_renzel(self): search_url = f'https://www.vkf-renzel.de/index.php?lang=0&cl=rasearch&searchparam={self.search_term}' self.driver.get(search_url) def suche_auf_boerner(self): search_url = f'https://www.boerner.de/?s={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.ID, "CookieBoxSaveButton") cookie_button.click() def suche_auf_ggmgastro(self): search_url = f'https://www.ggmgastro.com/de-de-eur/search?q={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "cf1y60") cookie_button.click() def suche_auf_boettcher(self): search_url = f'https://www.bueromarkt-ag.de/Artikelsuche_{self.search_term}.html' # Bitte die tatsächliche URL einsetzen self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "autocomplete-0-input"))) def suche_auf_bueroshop24(self): search_url = 'https://www.bueroshop24.de/' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "searchTerm"))) # Suchbegriff eingeben und Suche starten search_box = self.driver.find_element(By.ID, "searchTerm") search_box.clear() # Falls vorheriger Text vorhanden ist search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_buchhandlung_am_markt(self): search_url = f'https://bam-mr.buchkatalog.de/search?q={self.search_term}' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "mobile-search"))) def suche_auf_labelident(self): search_url = f'https://www.labelident.com/catalogsearch/result/?q={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "cmpboxbtn.cmpboxbtnno.cmptxt_btn_no") cookie_button.click() kunde = self.driver.find_element(By.CLASS_NAME, "btn.btn-blue-outline.redir-mask") kunde.click() def suche_auf_transpak(self): search_url = f'https://www.shop.transpak.de/search?sSearch={self.search_term}' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "form-control"))) try: # Warten, bis der Ablehnen-Button sichtbar ist cookie_button = WebDriverWait(self.driver, 10).until( EC.presence_of_element_located((By.XPATH, "//button[@data-cookiefirst-action='reject']")) ) # Klicken Sie auf den Ablehnen-Button, um Cookies abzulehnen cookie_button.click() except Exception as e: print(f"Fehler beim Akzeptieren von Cookies: {e}") def suche_auf_pml(self): search_url = f'https://www.pml-papiere.de/#query={self.search_term}' self.driver.get(search_url) def suche_auf_dmfolien(self): search_url = f'https://www.dm-folien.com/shop/search?sSearch={self.search_term}' self.driver.get(search_url) def suche_auf_proficleanshop(self): search_url = f'https://www.proficleanshop.de/searchresults/?q={self.search_term}' self.driver.get(search_url) kunde = self.driver.find_element(By.CLASS_NAME, "buttonTaxConfirm.fsize14.white") kunde.click() cookie_button = self.driver.find_element(By.CLASS_NAME, "cf1lHZ.cf2MAH") cookie_button.click() def suche_auf_siepmann(self): search_url = f'https://www.siepmann.net/siepmann_shop.php?suchfeld={self.search_term}' self.driver.get(search_url) def suche_auf_fksoehnchen(self): search_url = f'https://www.fk-soehnchen.de/index.php?lang=0&cl=search&searchparam={self.search_term}' self.driver.get(search_url) def suche_auf_wahl_agrar(self): search_url = 'https://www.agrar-fachversand.com/de/' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "main-search--field"))) # Auf die Suchleiste klicken search_box = self.driver.find_element(By.CLASS_NAME, "main-search--field") search_box.click() search_box.clear() search_box.send_keys(self.search_term) search_box.send_keys(Keys.RETURN) def suche_auf_tvv(self): search_url = f'https://www.tvv-verpackungen.de/index.php?jtl_token=86147d041429ad7dafb0c5f1a80e61e089eb4f04ec192b004ba5e69e8aaa45c5&sp_additional_mail=&qs={self.search_term}' self.driver.get(search_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "search-header-mobile-top"))) cookie_button = self.driver.find_element(By.CLASS_NAME, "cmpboxbtn.cmpboxbtnno.cmptxt_btn_no") cookie_button.click() def suche_auf_eierschachteln(self): search_url = f'https://www.eierschachteln.de/search?sSearch={self.search_term}' self.driver.get(search_url) cookie_button = self.driver.find_element(By.ID, "cookie-permission--accept-only-functional-button") cookie_button.click() def suche_auf_kox(self): search_url = f'https://www.kox-direct.de/?query={self.search_term}&sid=6d0b4366af8bb99af514529b7e61ad&act=search' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "od-btn-white.bg-gray-lightest.w-full.mb-4.set_essential_cookies") cookie_button.click() def suche_auf_reinigungsberater(self): search_url = f'https://www.reinigungsberater.de/{self.search_term}.html' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "acceptMe") cookie_button.click() def suche_auf_vbshobby(self): search_url = f'https://www.vbs-hobby.com/suche/?q={self.search_term}' self.driver.get(search_url) def suche_auf_oekonomed(self): search_url = f'https://shop.oekonomed.de/de/advanced_search_result.php?keywords={self.search_term}&inc_subcat=1' self.driver.get(search_url) cookie_button = self.driver.find_element(By.CLASS_NAME, "as-oil-l-item") cookie_button.click() def suche_auf_rossmann(self): search_url = f'https://www.rossmann.de/de/search/?text={self.search_term}' self.driver.get(search_url) def suche_auf_betzold(self): search_url = f'https://www.betzold.de/search/?q={self.search_term}' self.driver.get(search_url) class WebseitenSucheApp(QWidget): def __init__(self): super().__init__() self.categories, self.webpages = self.get_categories_and_webpages() self.checkbox_states = {webpage: False for category_webpages in self.webpages for webpage in category_webpages} self.search_term = "" self.driver = None self.init_ui() def get_categories_and_webpages(self): connection = sqlite3.connect('webseiten.db') cursor = connection.cursor() cursor.execute("SELECT name FROM categories") categories = [row[0] for row in cursor.fetchall()] webpages = [] for category in categories: cursor.execute("SELECT name FROM webpages WHERE category_id = (SELECT id FROM categories WHERE name = ?)", (category,)) webpages.append([row[0] for row in cursor.fetchall()]) # Verbindung schließen connection.close() return categories, webpages def init_ui(self): self.setStyleSheet("background-color: black; color: white;") layout = QVBoxLayout() # Kategorien und Webseiten in zwei vertikalen Spalten grid_layout = QGridLayout() grid_layout.setVerticalSpacing(5) # ... # Add category in the first grid############################################################# num_columns = 2 # Anzahl der Spalten for idx, category in enumerate(self.categories): category_label = QLabel(category) # Webseiten für die aktuelle Kategorie connection = sqlite3.connect('webseiten.db') cursor = connection.cursor() cursor.execute("SELECT name FROM webpages WHERE category_id = (SELECT id FROM categories WHERE name = ?)", (category,)) category_webpages = [row[0] for row in cursor.fetchall()] connection.close() num_webpages = len(category_webpages) # Hier kannst du die Anzahl der Zeilen und die Position für jede Kategorie individuell festlegen num_rows_for_category = max(num_webpages, 1) # Mindestens eine Zeile if category == "Baumarkt": row_position = 0 # Starte die Kategorie "Baumarkt" in der ersten Reihe elif category == "Schilder": row_position = 4 elif category == "Hygiene": row_position = 9 elif category == "Drogentest": row_position = 11 elif category == "Büro Artikel": row_position = 13 elif category == "Küchenbedarf": row_position = 17 elif category == "Landwirtschaft/Garten": row_position = 25 elif category == "Verpackungen": row_position = 12 elif category == "Reinigungs Artikel": row_position = 19 elif category == "Arbeitsschutz": row_position = 24 elif category == "Deko": row_position = 27 else: row_position = idx * (num_rows_for_category + 1) # 1 zusätzliche Zeile für die Kategorie col_position = idx % num_columns grid_layout.addWidget(category_label, row_position, col_position * 2, 1, 2) # Col Position * 2, um den Abstand zu erhöhen for row, webpage in enumerate(category_webpages): checkbox = QCheckBox(webpage) checkbox.setChecked(self.checkbox_states[webpage]) checkbox.stateChanged.connect(self.make_checkbox_callback(webpage)) checkbox.setStyleSheet("color: white; border: 1px solid white;") # Hier kannst du Anpassungen für jede Kategorie vornehmen if category == "IT/Elektronik": green_webpages = ["Reichelt", "Kosatec", "Conrad"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") yellow_webpages = [] if any(yellow_webpage in webpage for yellow_webpage in yellow_webpages): checkbox.setStyleSheet("color: yellow;") if category == "Schilder": green_webpages = ["Brewes","Schildershop24","Skiltex","VKF-Renzel"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") if category == "Hygiene": green_webpages = ["Rossmann"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") if category == "Drogentest": green_webpages = ["Ökonomed"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") if category == "Büro Artikel": green_webpages = ["Böttcher","Buchhandlung am Markt"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") yellow_webpages = ["Büroshop24.de"] if any(yellow_webpage in webpage for yellow_webpage in yellow_webpages): checkbox.setStyleSheet("color: yellow;") if category == "Küchenbedarf": green_webpages = ["Esmeyer","Lusini","Tischwelt","Schafferer","Gastronomie Kaufhaus"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") yellow_webpages = ["Börner","GGM-Gastro"] if any(yellow_webpage in webpage for yellow_webpage in yellow_webpages): checkbox.setStyleSheet("color: yellow;") if category == "Landwirtschaft/Garten": green_webpages = ["Siepmann","FK-Söhnchen","Wahl-Agar","KOX"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") if category == "Baumarkt": green_webpages = ["Hornbach","Contorion","Gastroteile Shop","Megabad","Baubeschlagshop","TiroLED","Esska"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") yellow_webpages = ["Häfele","Delker","Knauss","IPS"] if any(yellow_webpage in webpage for yellow_webpage in yellow_webpages): checkbox.setStyleSheet("color: yellow;") if category == "Verpackungen": green_webpages = ["Papstar","Pacovis","Transpak","TVV-Verpackungen","Eierschachteln.de","DM-Folien"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") if category == "Reinigungs Artikel": green_webpages = ["Hygi","Proficlean Shop","Reinigungsberater","Franz-Mensch"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") if category == "Arbeitsschutz": yellow_webpages = ["ARA","Arbeitsplatzmatten Profi"] if any(yellow_webpage in webpage for yellow_webpage in yellow_webpages): checkbox.setStyleSheet("color: yellow;") if category == "Deko": green_webpages = ["Frank-Flechtwaren","Betzold","VBS-Hobby"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") if category == "Etiketten/Papier": green_webpages = ["Label-Ident","PML"] if any(green_webpage in webpage for green_webpage in green_webpages): checkbox.setStyleSheet("color: green;") grid_layout.addWidget(checkbox, row + 1 + row_position, col_position * 2, 1, 2) # Setze den Stretch-Faktor für die zusätzliche Zeile zwischen den Kategorien grid_layout.setRowStretch(row_position + num_rows_for_category, 0) layout.addLayout(grid_layout) self.setLayout(layout) # Suchbegriff-Eingabe self.search_label = QLabel("Geben Sie den Suchbegriff ein:") layout.addWidget(self.search_label) self.search_input = QLineEdit(self) self.search_input.textChanged.connect(self.update_search_term) layout.addWidget(self.search_input) self.search_input.setStyleSheet("color: white; border: 1px solid white;") # Suchen-Button search_button = QPushButton("Suche starten", self) search_button.clicked.connect(self.start_search) layout.addWidget(search_button) search_button.setStyleSheet("color: white; border: 1px solid white;") # Neues Suche-Button new_search_button = QPushButton("Neue Suche starten", self) new_search_button.clicked.connect(self.clear_checkboxes) layout.addWidget(new_search_button) new_search_button.setStyleSheet("color: white; border: 1px solid white;") self.setLayout(layout) self.setGeometry(300, 300, 400, 200) self.setWindowTitle('Webseiten Suche App') self.show() def make_checkbox_callback(self, webpage): def checkbox_callback(state): self.checkbox_states[webpage] = state == Qt.Checked return checkbox_callback def update_webpage_state(self, webpage, state): self.checkbox_states[webpage] = state for checkbox in self.findChildren(QCheckBox): if checkbox.text() == webpage: checkbox.setChecked(state) def clear_checkboxes(self): for webpage in self.checkbox_states: self.update_webpage_state(webpage, False) self.search_input.clear() def update_search_term(self, text): self.search_term = text def start_search(self): checkbox_states = [webpage for webpage, selected in self.checkbox_states.items() if selected] if not checkbox_states: QMessageBox.warning(self, "Fehler", "Bitte wählen Sie mindestens eine Webseite aus.") return if not self.search_term: QMessageBox.warning(self, "Fehler", "Bitte geben Sie einen Suchbegriff ein.") return # Starte den Such-Thread self.search_thread = SearchThread(checkbox_states, self.search_term) self.search_thread.search_finished.connect(self.search_finished) self.search_thread.start() def search_finished(self): self.search_thread.quit() self.search_thread.wait() if hasattr(self.search_thread, 'error_message') and self.search_thread.error_message: QMessageBox.critical(None, "Fehler", self.search_thread.error_message) def keyPressEvent(self, event): if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return: self.start_search() if __name__ == '__main__': app = QApplication(sys.argv) window = WebseitenSucheApp() sys.exit(app.exec_())