猿问

网页抓取:如何测试根标签是否具有特定的 CSS 类?

我有一个包含这些内容的汤对象:


<tr class="x--player-is-starter">

<td class="pos" style="display: none; height: 62px;">10</td>

<td class="name" style="display: none; height: 62px;">

<a class="player-profile-link" href="/eurocupwomen/18-19/player/Maria-Conde" target="_blank"> Maria Conde</a>

</td>

<td class="min" style="height: 62px;">29:37</td>

<td class="pts" style="height: 62px;">13</td>

<td class="field-goals" style="height: 62px;">

<span class="made-all">4/8</span>

<span class="percent">50%</span>

</td>

<td class="field-goals-2p" style="height: 62px;">

<span class="made-all">1/2</span>

<span class="percent">50%</span>

</td>

<td class="field-goals-3p" style="height: 62px;">

<span class="made-all">3/6</span>

<span class="percent">50%</span>

</td>

<td class="free-throw" style="height: 62px;">

<span class="made-all">2/4</span>

<span class="percent">50%</span>

</td>

<td class="reb-offence" style="height: 62px;">2</td>

<td class="reb-defence" style="height: 62px;">0</td>

<td class="reb-total" style="height: 62px;">2</td>

<td class="assists" style="height: 62px;">3</td>

<td class="personal-fouls" style="height: 62px;">0</td>

<td class="turnovers" style="height: 62px;">1</td>

<td class="steals" style="height: 62px;">3</td>

<td class="block-shots" style="height: 62px;">0</td>

<td class="plus-minus" style="height: 62px;">2</td>

<td class="efficiency" style="height: 62px;">14</td>

</tr>

我想知道如何知道标签“tr”是否有 CSS class = "x--player-is-starter"。


例如,如果这个包含上述tr内容的对象被称为row,我曾尝试使用row.find("tr", class_="x--player-is-starter"),但结果总是得到“无”。


那么,我如何知道"tr"标签是否具有我要查找的 CSS 类?难道我做错了什么?


万千封印
浏览 148回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答