0

I am trying to get numbers that are siblings with others HTML tags inside a common DIV, as follows:

<div class="opciones">
  1 
  <i class="fa fa-heart"></i>
  <a href="o/39082" class="boton">Ver Iniciativa</a>
</div>

This is what I have been trying:

apoyos = soup.select('div.card > div:nth-of-type(3)')
valor_apoyo = [valor.text for valor in apoyos]
valor_apoyo

Result:

['\n\t\t\t1 \nVer Iniciativa\n',
'\n\t\t\t56 \nVer Iniciativa\n',
'\n\t\t\t21 \nVer Iniciativa\n',
...
...
]

Not too bad, but not awesome as I would like! At least my target is just there!

I just need to get the bare number.

[1, 56, 21, ...]

Any help will be much appreciated.

0 Answers0