Repaired several bugs and database connection is setup and connects, scrapper just seems not to be scrapping just yet
This commit is contained in:
parent
a645184cff
commit
277e4dcf1e
Binary file not shown.
Binary file not shown.
|
@ -9,17 +9,24 @@ class Scrapper:
|
|||
self.ui_instance = ui_instance
|
||||
self.visited_links = set()
|
||||
self.running=False
|
||||
self.lock() = threading.Lock()
|
||||
|
||||
self.lock = threading.Lock()
|
||||
|
||||
#Configurar la base de datos para los enlaces
|
||||
self.db.config = {
|
||||
self.db_config = {
|
||||
"host": "localhost",
|
||||
"user": "root",
|
||||
"password": "1234Scrap",
|
||||
"database": "scrap_links_db"
|
||||
"password": "",
|
||||
"database": "scrap_links_db",
|
||||
"port": 3306
|
||||
}
|
||||
|
||||
try:
|
||||
connection = mysql.connector.connect(**self.db_config)
|
||||
print("Conexion exitosa a base de datos")
|
||||
connection.close()
|
||||
except Exception as e:
|
||||
print(f"Error al conectar a la base de datos: {e}")
|
||||
|
||||
def start_scraping(self):
|
||||
"""Inicia el proceso de scraping"""
|
||||
self.running = True
|
||||
|
@ -62,10 +69,9 @@ class Scrapper:
|
|||
text_widget.insert("end", f"Enlaces encontrados en {url}:\n")
|
||||
for link in links:
|
||||
text_widget.insert("end", f" - {link}\n")
|
||||
text_widget.insert("end", "\n")
|
||||
text_widget.see("end")
|
||||
|
||||
def save_links_to_db(self, url, links)
|
||||
def save_links_to_db(self, url, links):
|
||||
"""Guarda los enlaces en la base de datos"""
|
||||
try:
|
||||
connection = mysql.connector(**self.db_config)
|
||||
|
@ -75,6 +81,7 @@ class Scrapper:
|
|||
cursor.execute("INSERT INTO links (url, parent_url) VALUES (%s, %s)", (link, url))
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
connection.close()
|
||||
except:
|
||||
print(f"Error al gaurdar en la base de datos")
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class SystemMonitor:
|
|||
},
|
||||
"Processes": {
|
||||
"data": [],
|
||||
"fetch_func": lambda: self.get_process_count,
|
||||
"fetch_func": self.get_process_count,
|
||||
"interval": 1
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -102,7 +102,7 @@ class CenteredWindow(ctk.CTk):
|
|||
start_button.pack(pady=5, padx=10)
|
||||
|
||||
stop_button = ctk.CTkButton(left_panel, text="Detener Scrapping", command=self.thread_manager.tasks["scrapper"].stop)
|
||||
stop_button.pack("pady=5, padx=10")
|
||||
stop_button.pack(pady=5, padx=10)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue