diff --git a/.idea/PrgServicios.iml b/.idea/PrgServicios.iml index a80cbb1..405ee04 100644 --- a/.idea/PrgServicios.iml +++ b/.idea/PrgServicios.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index f8a22e9..1f9c218 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/ejercicios/__init__.py b/ejercicios/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ejercicios/paralelismo02/ej01/__init__.py b/ejercicios/paralelismo02/ej01/__init__.py new file mode 100644 index 0000000..b6f984f --- /dev/null +++ b/ejercicios/paralelismo02/ej01/__init__.py @@ -0,0 +1,3 @@ +from ejercicios.paralelismo02.ej01.ej01 import MiScraping + +hilo = MiScraping("") \ No newline at end of file diff --git a/ejercicios/paralelismo02/ej01.py b/ejercicios/paralelismo02/ej01/ej01.py similarity index 56% rename from ejercicios/paralelismo02/ej01.py rename to ejercicios/paralelismo02/ej01/ej01.py index db9d979..1d00b46 100644 --- a/ejercicios/paralelismo02/ej01.py +++ b/ejercicios/paralelismo02/ej01/ej01.py @@ -4,16 +4,16 @@ from bs4 import BeautifulSoup import re class MiScraping(threading.Thread): - def __init__(self,url): threading.Thread.__init__(self) self.url = url self.links =[] def run(self): - # self.url coge el "url" que se le pase al constructor a la hora de llamar al metodo response = requests.get(self.url) - - + soup = BeautifulSoup(response.text,"html.parser") + self.links = [a['href'] for a in soup.find_all('a', href=True) if re.match(r'http[s]?://', a['href'])] + def get_links(self): + return self.links