python - find_element_by_class_name 类空间不起作用
问题描述
我正在尝试使用find_element_by_class_name
班级有空格但不起作用的地方:
这是代码:
<a class="yt-simple-endpoint style-scope yt-formatted-string" href="/user/santanderbrasil">Santander Brasil</a>
我想要获取内容“桑坦德巴西”
我尝试了以下方法:
driver.find_element_by_class_name("yt-simple-endpoint.style-scope.yt-formatted-string")
driver.find_element_by_class_name("a.yt-simple-endpoint.style-scope.yt-formatted-string")
和
driver.find_element_by_class_name("a.yt-simple-endpoint.")
没有一个工作...
有什么帮助吗?
解决方案
请改用 css 选择器功能。
driver.find_element_by_css_selector("a.yt-simple-endpoint.style-scope.yt-formatted-string")
推荐阅读
- xml-parsing - 使用 Informatica Cloud 解析 XML
- for-loop - 批处理:文件中的 for 循环问题与名称中的符号有关
- amazon-web-services - 用于静态图像的 Laravel Vapor + S3 存储桶 - 使用域 url
- java - NullPointerException:尝试从空对象引用上的字段“int com.google.android.gms.location.LocationRequest.a”读取
- python - 如何在python中对日历年数据进行自定义时间(半月和10天)拆分?
- javascript - CodeMirror 禁止某些字符的输入
- python - 从数据框中绘制多个时间序列
- javascript - 使用 API 创建天气应用程序,我正在尝试显示图标
- kotlin - `@sample` 在 ktdoc 中是如何使用的?
- android - 无法更改 Android Studio 上 FloatingActionButton 布局文件中的图标颜色