Scraping <span> tag with BeautifulSoup

  beautifulsoup, html, python

I am trying to scrape a page with BeautifulSoup and there are < script> tags inside < span> tag as shown below

<span data-link="{include tmpl='productCardOrderCount' ^~ordersCount=selectedNomenclature^ordersCount}"><script type="jsv#28_"></script>
<script type="jsv#27^"></script>
<script type="jsv#29_"></script>
<script type="jsv#26^"></script>
более 20 раз
<script type="jsv/26^"></script>
<script type="jsv/29_"></script>
<script type="jsv/27^"></script>
<script type="jsv/28_"></script>
</span>

But as < script> tags are not parsed as HTML in bs4, following code returns < span> tag without the text ("более 20 раз")

rating = soup.find("p", {"class": "order-quantity"})

How can I get the text within the tag?

Source: Python Questions

LEAVE A COMMENT