如何在Python Selenium Web Driver中获取Div属性文本
希望一切都很好。我想获得“数据ID”属性文本。请任何人帮助我在这里得到这一点。提前致谢。
<div class="_1AtVbE col-12-12">
<div class="_13oc-S">
<div data-id="MOBG6WQWRGRRDBH6" style="width: 100%;">
<div class="_2kHMtA" data-tkid="82daf062-714d-464f-b670-ce7681250431.MOBG6WQWRGRRDBH6.SEARCH">
</div>
</div>
</div>
</div>
Hope all are doing well. I want to get "data-id" property text. Please anyone help me here to get that. Thanks in advance.
<div class="_1AtVbE col-12-12">
<div class="_13oc-S">
<div data-id="MOBG6WQWRGRRDBH6" style="width: 100%;">
<div class="_2kHMtA" data-tkid="82daf062-714d-464f-b670-ce7681250431.MOBG6WQWRGRRDBH6.SEARCH">
</div>
</div>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用CSS选择器查找具有数据ID属性的DIV元素
注意:由于您的HTML样本很小,因此该代码可以工作。在更大的样本上,缩小到目标div元素的父,或使用
find_elements
而不是要过滤您想要的元素。参考阅读:所有CSS属性选择器
Use CSS selector to find div element with data-id attribute
Note: since your HTML sample is small this code would work. On a bigger sample, narrow down to the parent of your target div element, or use
find_elements
instead and filter for the element you want.Reference reading: All CSS Attribute Selectors