A
A
Alexey Orlov2020-05-12 14:34:24
Python
Alexey Orlov, 2020-05-12 14:34:24

Python data parsing and the br tag?

How to properly parse data separately if, for example, two different attributes are present in one tag and are separated by the 'br' tag.

For example:

<div class="block">
Имя: Алексей
<br/>
Возраст: 25 лет
</div>


I get data from this block as follows:
NameAndAge = soup.find_all(class_='block')[i].get_text()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-05-12
@LeshaGFB

name, _, age = list(soup.find_all(class_='block')[0].children)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question