Answer the question
In order to leave comments, you need to log in
How to parse a block in Python?
Why is Beautiful Soup parsing this block incorrectly?
Here is a simplified code, the bug is also reproduced on it:
soupIndex = BeautifulSoup('''<div class="vk-comment">
<div class="vk-avatar">
<img src="img.png">
</div>
<div class="vk-comment-name">
Имя автора
</div>
<div class="vk-comment-text">
<p>
Текст коммента
</p>
</div>
<div class="vk-comment-date">
17 минут назад
</div>
</div>''')
template = soupIndex.select_one('.vk-comment')
print(template)
Answer the question
In order to leave comments, you need to log in
The problem was in the wrong display in the console, wrote the data to a file, it is normally displayed there.
do you need data from all div s?
for i in soupIndex.find_all('div'):
print(i['class'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question