G
G
glbtsk212021-07-16 13:58:38
Python
glbtsk21, 2021-07-16 13:58:38

How to parse the span attribute?

Good afternoon, from this code you need to parse only the value "House", how to do this? Thank you.

<ul class="product-item_params">
                                                            <li>
                                    <span class="product-item_params_name">Бренд:</span>
                                    <span class="product-item_params_value">Домик </span>
                                </li>
                                                    </ul>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-16
@SoreMix

from bs4 import BeautifulSoup


soup = BeautifulSoup('''<html lang="en"><body><ul class="product-item_params">
                                                            <li>
                                    <span class="product-item_params_name">Бренд:</span>
                                    <span class="product-item_params_value">Домик </span>
                                </li>
                                                    </ul></body></html>''', 'html.parser')

print(soup.find('span', {'class': 'product-item_params_value'}).text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question