[英]Selenium Finding elements in python
如何获得价值View View ?
<tr class="">
<td class=" _100u">
<label class="_55sg _kv1">
<input name="select_single_row_checkbox[]" type="checkbox" value="100010456172450">
<span class="_66ul"></span>
</label>
</td>
<td class=" _100u">
<div direction="left" class="clearfix">
<div class="_ohe lfloat">
<img src="https://graph.facebook.com/100010456172450/picture?width=32&height=32&access_token=2712477385668128|b429aeb53369951d411e1cae8e810640" class="img _8o _8r img" alt="">
</div>
<div class="">
<div class="_42ef _8u">
<div>
<a data-hovercard="/ajax/hovercard/user.php?id=100010456172450" class="_3cb8" href="/100010456172450">View View</a>
</div>
</div>
</div>
</div>
</td>
<td class=" _100u">
<abbr aria-label="3 weeks ago" class="livetimestamp" data-utime="1606705616">11/30/20</abbr>
</td>
</tr>
我尝试编写下面的代码但不返回任何结果并且程序保持运行
for a in driver.find_elements_by_xpath("//*[@class='_3cb8']").getAttribute("href")
print(a.text)
elements = WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.CLASS_NAME, "_3cb8")))
for a in elements
print(a.get_attribute('textContent'))
你为什么得到属性href? 只需删除它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.