如何使用selenium从类中获取文本

2024-04-26 11:02:49 发布

您现在位置:Python中文网/ 问答频道 /正文

<div class="class-one">
<div class="class-two">
sample text
<div class="class-three">
<a href="https://google.com" target="" class="button button--outline button--purple " id="" title="search"><i class="fal fa-fw fa-file-word"></i><span class="button__title">search</span></a>
</div>
</div>
</div>

当我执行driver.find_elements_by_css_selector('div.class-two')时,它也会打印sample textsearch,如何在python中使用selenium仅获取示例文本


Tags: sampletexthttpsdivsearchtitlegooglebutton