I have the following html code:
<div>
<span class="test">
<span class="f1">
5 times
</span>
</span>
</span>
</div>
<div>
</div>
<div>
<span class="test">
<span class="f1">
6 times
</span>
</span>
</span>
</div>
I managed to navigate the tree, but when trying to print I get the following error:
AttributeError: 'list' object has no attribute 'text'
Python code working:
x=soup.select('.f1')
print(x)
gives the following:
[]
[]
[]
[]
[<span class="f1"> 19 times</span>]
[<span class="f1"> 12 times</span>]
[<span class="f1"> 6 times</span>]
[]
[]
[]
[<span class="f1"> 6 times</span>]
[<span class="f1"> 1 time</span>]
[<span class="f1"> 11 times</span>]
but print(x.prettify) throws the error above. I am basically trying to get the text between the span tags for all instances, blank when none and string when available.