Answer the question
In order to leave comments, you need to log in
How to get the content of data-tooltip through BeautifulSoup?
Let's say we have this html code:
<tr class="gray">
<td class="p1" ....</td>
......
<td class="p3">
<div data-tooltip='QWERTY' class='ToolTip'>12345</div>
</td>
Answer the question
In order to leave comments, you need to log in
I'm not sure if this is the most direct way, but something like this is possible:
from bs4 import BeautifulSoup
data = '''
<td class="p3">
<div data-tooltip='QWERTY' class='ToolTip'>12345</div>
</td>'''
soup = BeautifulSoup(data,'html.parser')
div = soup.find('div') # тут вы уж сами найдите нужный вам div, я просто моделирую типа мы его нашли.
tag = 'data-tooltip'
print(div.attrs[tag])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question