Beautifulsoap loop

1

I am trying to select a series of elements within a web page. Actually 6. Using this code I get the elements I want but also many elements that I do not want, after the sixth.

How could you program a loop that only selects the first 6 elements that are called class_="bold" and their siblings?

for negritas in soup.find_all(class_ = "negritas"):
  print (negritas.get_text())
  print (negritas.nextSibling.get_text())

try this code but I do not understand how to tell you that only the first 6:

divs = soup.findAll(class_= 'negritas')    
for div in divs:

    div.find()
    
asked by Carlos Ruz 03.05.2018 в 02:53
source

0 answers