From 39b90ed7a2fac5b28cd0d5bd170daf507866447a Mon Sep 17 00:00:00 2001 From: Juanjo Date: Tue, 29 Oct 2024 13:54:33 +0100 Subject: [PATCH] first commit --- README.md | 1 + _servidorweb_/1.html | 13 ++++++++ _servidorweb_/2.html | 13 ++++++++ _servidorweb_/index.html | 11 +++++++ bbdd/__init__.py | 0 bbdd/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 143 bytes bbdd/__pycache__/guardar.cpython-312.pyc | Bin 0 -> 1345 bytes bbdd/guardar.py | 31 ++++++++++++++++++ main.py | 13 ++++++++ scraping/__init__.py | 0 scraping/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 147 bytes scraping/__pycache__/busca.cpython-312.pyc | Bin 0 -> 1475 bytes scraping/busca.py | 18 ++++++++++ 13 files changed, 100 insertions(+) create mode 100644 README.md create mode 100644 _servidorweb_/1.html create mode 100644 _servidorweb_/2.html create mode 100644 _servidorweb_/index.html create mode 100644 bbdd/__init__.py create mode 100644 bbdd/__pycache__/__init__.cpython-312.pyc create mode 100644 bbdd/__pycache__/guardar.cpython-312.pyc create mode 100644 bbdd/guardar.py create mode 100644 main.py create mode 100644 scraping/__init__.py create mode 100644 scraping/__pycache__/__init__.cpython-312.pyc create mode 100644 scraping/__pycache__/busca.cpython-312.pyc create mode 100644 scraping/busca.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..bbd18d4 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Ejercicio Thread04 diff --git a/_servidorweb_/1.html b/_servidorweb_/1.html new file mode 100644 index 0000000..9469c1a --- /dev/null +++ b/_servidorweb_/1.html @@ -0,0 +1,13 @@ + + + + + + Página 1 + + + Ir a página 2 +
+ Volver + + \ No newline at end of file diff --git a/_servidorweb_/2.html b/_servidorweb_/2.html new file mode 100644 index 0000000..083388b --- /dev/null +++ b/_servidorweb_/2.html @@ -0,0 +1,13 @@ + + + + + + Página 2 + + + Ir a página 1 +
+ Volver + + \ No newline at end of file diff --git a/_servidorweb_/index.html b/_servidorweb_/index.html new file mode 100644 index 0000000..5d91b08 --- /dev/null +++ b/_servidorweb_/index.html @@ -0,0 +1,11 @@ + + + + + + Inicio + + + Ir a página 1 + + \ No newline at end of file diff --git a/bbdd/__init__.py b/bbdd/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bbdd/__pycache__/__init__.cpython-312.pyc b/bbdd/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8463599fcc7406976ae0322017038e250006d63f GIT binary patch literal 143 zcmX@j%ge<81fPTz(n0iN5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!(o43AaS4lYDatQM z%CCqis4U6I&x0O-v9sr literal 0 HcmV?d00001 diff --git a/bbdd/__pycache__/guardar.cpython-312.pyc b/bbdd/__pycache__/guardar.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2861fa8eb7aee4c1e485e5cb28801b3b271e4953 GIT binary patch literal 1345 zcmcIk-D?wB6hC)9l1V#BNE<&|O*^(KrqYVqCt0?*ZID8VP(MHkl*!zyZAdcl-U&%c zqRX-m4G5`EU04=;UFu(9ANOU;c4@e~FQPBL1>=M0i+7S4D-_fh56qn3{hf2q$35Kp zS2#QXLMBFx`-?KbOLyUm9 z$34)efgW!tpVb_!E5E}Z(m~~S#M~OnL*;R{uPdkmRrwB7(ByaTssetlq?YEPylt8J zRhv0H=&Vv=;#sa-ymWassc@x7D`iF~*GeX16`NwNVbd|QCL`+?7SlIU%Qub1Yw7FD zDPu8x^SVKbdD9}yIM)YB_MJ~EW21FmSa;M^dJvdWy)NFREbq~h#>4jVa?%ciLMoe>P6xD z8e8$U5X@C8Z!?lqg>$b2t_hpSZWpOLz}}LT^Nz`7LMd}EfZ@vfY3oX6;dW+$+NG>r z&6H}+s$I9<2?N;Mw$@JhdZp;oe(j*4*Z{bMi0?`P;pqiW*S@bRs= zCv*G5Q@g`c?byk7Y_xskMEl5CCj{~HT~Ol#8(JpcPsaa=O>6`@0f?v2hSt_1 ztw=MnS$%r;>BydTUhttG{1YO#iE&?5LnmzIz)2J=U6Q&h=g208+>Q*TS2@-{j5mhP|(i?P_BmIQs<+v6I2DWqsuOiUS5#oq|BqeY0rEbHgz9^ t-l_cwT>*iPh#%K}DA>51CqL3Lv2>pS=DrJ}IE4O#qg~|$O3;L0J^~8lAf^BS literal 0 HcmV?d00001 diff --git a/bbdd/guardar.py b/bbdd/guardar.py new file mode 100644 index 0000000..feef718 --- /dev/null +++ b/bbdd/guardar.py @@ -0,0 +1,31 @@ +import mysql.connector + +def guardar_enlace_en_bd(cadena): + try: + # Conexión a la base de datos + conexion = mysql.connector.connect( + host="localhost", + user="thread4", + password="1234", + database="thread4" + ) + + cursor = conexion.cursor() + + # Consulta para insertar la cadena + consulta = "INSERT IGNORE INTO enlaces (enlace) VALUES (%s)" + cursor.execute(consulta, (cadena,)) + + # Confirmar la transacción + conexion.commit() + + print("Cadena guardada exitosamente.") + + except mysql.connector.Error as err: + print(f"Error: {err}") + + finally: + if conexion.is_connected(): + cursor.close() + conexion.close() + diff --git a/main.py b/main.py new file mode 100644 index 0000000..3402829 --- /dev/null +++ b/main.py @@ -0,0 +1,13 @@ +from bbdd import guardar +from scraping.busca import MiScraping + +if __name__ == "__main__": + cadena = "https://www.google.com" + guardar.guardar_enlace_en_bd(cadena) + + MiObjScraping = MiScraping("https://ieslamar.org") + MiObjScraping.start() + MiObjScraping.join() + links = MiObjScraping.get_links() + for link in links: + print(link) \ No newline at end of file diff --git a/scraping/__init__.py b/scraping/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scraping/__pycache__/__init__.cpython-312.pyc b/scraping/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..243bdb7e389b9e471c2aebe73a929cfd4ab61f9e GIT binary patch literal 147 zcmX@j%ge<81o~GL(n0iN5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!GD^0JaS4lYDatQM z%CCqis4U6I&xY}jaNd46Yv;oRH#A9c6}Oe>A~m_>6h)w-C`d@nfm8??ht+0x>>Q%)I%YdHdt& zXbKSKpUxD=B!J(Di9ziXz4wu5gAF!wAs?MA&ybf~sUqiP7Ri*nBEh?0%iCZp4wOUB zv9strkfSr7XfR#PBhR;%2Sn6)h}h02G$K-p7dA;14d!r?vXha$NX83!nuD{Y)6NSPP7P zApk|ZGn81h0sCwP6G{4;+%av;BS_o~$v`uVl2`H#BarLd4OF+}-4ePKD8g|!_%M19 zl+4V`-*eVNVd;ay60g?Qt9J^uhQC?$3X#Wa^99kbu&`bimN{E%aO!k3^Ro8YIMfh% zy@Kd2Jk!RHw8^eEd8FmKT5j*k6YY)T%xgQ!u68_eenf{&w6P=jX>I8_+PyzVu}PK_OT zav>Z_fdEA23&?`Y4`uRr|o%e61o9^E)hFYGAC`n7Mf``Pcr_vapE zpXken6JA$e-n;(OrJt|?lnJccC;y;M!|}npjYRa6$f8k$}lQbyY3P_Vi>pUrW@Ua&xc)=A<63Gi