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,16 +9,23 @@ class Scrapper:
|
||||||
self.ui_instance = ui_instance
|
self.ui_instance = ui_instance
|
||||||
self.visited_links = set()
|
self.visited_links = set()
|
||||||
self.running=False
|
self.running=False
|
||||||
self.lock() = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
|
|
||||||
|
#Configurar la base de datos para los enlaces
|
||||||
|
self.db_config = {
|
||||||
|
"host": "localhost",
|
||||||
|
"user": "root",
|
||||||
|
"password": "",
|
||||||
|
"database": "scrap_links_db",
|
||||||
|
"port": 3306
|
||||||
|
}
|
||||||
|
|
||||||
#Configurar la base de datos para los enlaces
|
try:
|
||||||
self.db.config = {
|
connection = mysql.connector.connect(**self.db_config)
|
||||||
"host": "localhost",
|
print("Conexion exitosa a base de datos")
|
||||||
"user": "root",
|
connection.close()
|
||||||
"password": "1234Scrap",
|
except Exception as e:
|
||||||
"database": "scrap_links_db"
|
print(f"Error al conectar a la base de datos: {e}")
|
||||||
}
|
|
||||||
|
|
||||||
def start_scraping(self):
|
def start_scraping(self):
|
||||||
"""Inicia el proceso de scraping"""
|
"""Inicia el proceso de scraping"""
|
||||||
|
@ -61,11 +68,10 @@ class Scrapper:
|
||||||
text_widget = tab.text_widget
|
text_widget = tab.text_widget
|
||||||
text_widget.insert("end", f"Enlaces encontrados en {url}:\n")
|
text_widget.insert("end", f"Enlaces encontrados en {url}:\n")
|
||||||
for link in links:
|
for link in links:
|
||||||
text_widget.insert("end", f" - {link}\n")
|
text_widget.insert("end", f" - {link}\n")
|
||||||
text_widget.insert("end", "\n")
|
text_widget.see("end")
|
||||||
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"""
|
"""Guarda los enlaces en la base de datos"""
|
||||||
try:
|
try:
|
||||||
connection = mysql.connector(**self.db_config)
|
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))
|
cursor.execute("INSERT INTO links (url, parent_url) VALUES (%s, %s)", (link, url))
|
||||||
connection.commit()
|
connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
except:
|
except:
|
||||||
print(f"Error al gaurdar en la base de datos")
|
print(f"Error al gaurdar en la base de datos")
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class SystemMonitor:
|
||||||
},
|
},
|
||||||
"Processes": {
|
"Processes": {
|
||||||
"data": [],
|
"data": [],
|
||||||
"fetch_func": lambda: self.get_process_count,
|
"fetch_func": self.get_process_count,
|
||||||
"interval": 1
|
"interval": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -102,7 +102,7 @@ class CenteredWindow(ctk.CTk):
|
||||||
start_button.pack(pady=5, padx=10)
|
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 = 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