Como usar python sopa bonita para obter apenas o nível 1 navigableText?
Estou usando uma linda sopa para obter o texto deste exemplo de código html:
....
<div style="s1">
<div style="s2">Here is text 1</div>
<div style="s3">Here is text 2</div>
Here is text 3 and this is what I want.
</div>
....
O texto 1 e o texto 2 estão no mesmo nível 2 e o texto 3 está no nível superior 1. Só quero obter o texto 3 e utilizá-lo:
for anchor in tbody.findAll('div', style="s1"):
review=anchor.text
print review
Mas esse código me pega todo o texto 1,2,3. Como faço para obter apenas o primeiro nível de texto 3?