Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72618

Cannot extract tags with classes specified in beautifulsoup

$
0
0

This is my first ever question. I have spent hours reading similar questions and I am sorry I still cannot figure out the problem here.

I am trying to parse a large html, the relevant part is this:

<li class="offer-params__item">
    <span class="offer-params__label">Classe der ware</span>
    <div class="offer-params__value">
        <a class="offer-params__link" href="https://www.bla.com">Classe 1</a>
    </div>
</li>

this is my code:

soup = BeautifulSoup(data, 'lxml')

parameters = soup.findAll("li", {"class" : "offer-params__item"}) 
print(len(parameters))

for item in parameters:
    for li in item:
        code = li.find_next('span').text.split('', maxsplit=1)[0]
    print(code)

Also, it prints len(parameters) as zero, it is not catching them. I also tried with regex without success.


Viewing all articles
Browse latest Browse all 72618

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>