I've used a selector in my python script to fetch the text from some html elements given below. I tried with .text
to get the Shop here cheap
string from the elements but it doesn't work at all. However, when I try with .text_content()
it works as it should.
My question is:
What's wrong with .text
method? Why couldn't it parse the text from the elements?
Html elements:
<div class="Price__container">
<span class="ProductPrice" itemprop="price">$6.35</span>
<span class="ProductPrice_original">$6.70</span>
Shop here cheap
</div>
What i tried with:
from lxml import html
tree = html.fromstring(element)
for data in tree.cssselect(".Price__container"):
print(data.text) #It doesn't work at all
Btw, I don't wish to go on with .text_content()
that is why I'm expecting any answer to scrape the text using .text
instead. Thanks in advance.