Scrapper works but shuts down with no errors
This commit is contained in:
parent
277e4dcf1e
commit
31e539c726
Binary file not shown.
|
@ -4,6 +4,8 @@ from bs4 import BeautifulSoup
|
|||
from urllib.parse import urljoin
|
||||
import mysql.connector
|
||||
|
||||
#http://books.toscrape.com/ test scrap web
|
||||
|
||||
class Scrapper:
|
||||
def __init__(self, ui_instance):
|
||||
self.ui_instance = ui_instance
|
||||
|
@ -32,7 +34,10 @@ class Scrapper:
|
|||
self.running = True
|
||||
url = self.get_url_from_ui()
|
||||
if url:
|
||||
print(f"Iniciando scraping en: {url}")
|
||||
self.scrape_page(url)
|
||||
else:
|
||||
print("No se proporcionó una URL válida.")
|
||||
|
||||
def stop_scraping(self):
|
||||
"""Detiene el proceso de scraping"""
|
||||
|
@ -65,11 +70,14 @@ class Scrapper:
|
|||
def update_ui(self, url, links):
|
||||
"""Actualiza la pestaña 'Scrapping' con los enlaces encontrados"""
|
||||
tab = self.ui_instance.tabs["Scrapping"]
|
||||
text_widget = tab.text_widget
|
||||
text_widget = tab["text_widget"]
|
||||
|
||||
text_widget.configure(state="normal")
|
||||
text_widget.insert("end", f"Enlaces encontrados en {url}:\n")
|
||||
for link in links:
|
||||
text_widget.insert("end", f" - {link}\n")
|
||||
text_widget.see("end")
|
||||
text_widget.configure(state="disabled")
|
||||
|
||||
def save_links_to_db(self, url, links):
|
||||
"""Guarda los enlaces en la base de datos"""
|
||||
|
|
Binary file not shown.
|
@ -118,6 +118,14 @@ class CenteredWindow(ctk.CTk):
|
|||
for tab_name in ["Scrapping", "Navegador", "Correos", "Juego", "Sistema"]:
|
||||
tab = tab_view.add(tab_name)
|
||||
|
||||
if tab_name == "Scrapping":
|
||||
text_widget = ctk.CTkTextbox(tab, width=500, height=400)
|
||||
text_widget.pack(fill=ctk.BOTH, expand=True, padx=10, pady=10)
|
||||
|
||||
text_widget.configure(state="disabled")
|
||||
|
||||
self.tabs = {"Scrapping": {"text_widget": text_widget}}
|
||||
|
||||
if tab_name == "Sistema":
|
||||
# Crear un frame para los gráficos del sistema
|
||||
system_frame = ctk.CTkFrame(tab)
|
||||
|
|
Loading…
Reference in New Issue