我使用 Python 和 Selenium。任务是单击带有文本'+like' 的按钮或带有class ='profile-image' 的列'td ' 。但是按钮没有 id 并且它的类“更多喜欢”用于其他按钮。具有类'profile-image-button'的div的情况相同(在其他'divs'中使用的div的类ID)。我试图获取'td' 的id :
button = photos.find('td', class_='profile-image')
print(button.get_id)
输出为“无”
这是网页的html代码:
<div id="category7515692" class="category-content" data-content="present" data-collapsing="true">
<table class="pictures" data-columns-count="12" data-type="gallery">
<tbody class="" data-selec="7565904" data-name="beauty" data-live="true">
<tr data-mutable-id="MR1main" class="header">
<td class="main-row-buttons" rowspan="1" data-mutable-id="Bmain">
<table>
<tbody>
<tr>
<td class="profile-image" id="view-75634" data-event-more-view="event-more-view" data-selec="7565904" islive="true" isseparatedbutton="false">
<div class="profile-image-button">
<span class="more-likes">+like</span>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
如何单击按钮或如何获取 id?