Duda Función Python al devolver una lista
Publicado por Jesus (1 intervención) el 09/03/2020 10:08:52
Necesito ayuda respecto a esta función que he realizado. Tengo que devolver "children_col", el cual contiene todos los elementos HTML de la clase "izq" de cada uno de los enlaces sobre los que se va iterando. SIn embargo, no me devuelve nada.
P.S: children_col es una variable global que he creado al principio.
P.S: children_col es una variable global que he creado al principio.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def html_data():
res2 = []
res = BeautifulSoup(html.read(), "html.parser")
children = res.findAll("td",{"class":"izq"})
for child in children:
res = child.find_all("a")
for res1 in res:
res1.attrs['href'] = "http://www.listadomanga.es/" + res1.attrs['href']
enlaces.append(res1.attrs['href'])
titulos.append(res1.string)
for i in range(len(enlaces)):
html2 = urlopen(enlaces[i])
col_html = BeautifulSoup(html2.read(),"html.parser")
res2 = col_html.findAll("td",{"class":"izq"})
for j in res2:
children_col.append(j)
return children_col
Valora esta pregunta


0