Answer the question
In order to leave comments, you need to log in
How to get data from cells?
How it is possible to pull out values - 1,2,3 from the table "Journal"? I did not find a suitable library. There is a table like:
<table id="journal" class="marks">
<tbody>
<tr>'
<td class="s2">
<strong class="u">HTML</strong>
</td>
<td class="tac">
<span class="mark mY analytics-app-popup-mark" data-num="0">1</span>
<span class="mark mY analytics-app-popup-mark" data-num="0">2</span>
<span class="mark mG analytics-app-popup-mark" data-num="0">3</span>
</td>
Answer the question
In order to leave comments, you need to log in
from lxml import etree
html = """
<table id="journal" class="marks">
<tbody>
<tr>
<td class="s2">
<strong class="u">HTML</strong>
</td>
<td class="tac">
<span class="mark mY analytics-app-popup-mark" data-num="0">1</span>
<span class="mark mY analytics-app-popup-mark" data-num="0">2</span>
<span class="mark mG analytics-app-popup-mark" data-num="0">3</span>
</td>
</tr>
</tbody>
</table>"""
tree = etree.fromstring(html)
for block in tree.xpath("//table[@id='journal']/descendant::span[starts-with(@class, 'mark')]"):
print(block.xpath("text()"))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question