【发布时间】:2022-12-01 04:34:25
【问题描述】:
我想使用 python 用 selenium 抓取一个测验,这里是 1 个答案选择的代码。
当它是正确的答案时,遗嘱包含这个特定的类,当它不正确时,它是这个的另一个类
所以我想得到答案正确的问题文本(产品对客户满意度的影响。) 这将取决于 < i > 中的类(因为正如我所说,当它的错误答案时,它是内部的另一个类)
但是我找不到如何用 XPATH 选择它
<div class='course-player__interactive-checkbox _interactive-checkbox_cjbh9b'>
<div class='course-player__interactive-checkbox__choice-label _interactive-checkbox__choice-label_cjbh9b'>
<span class='course-player__interactive-checkbox__choice-letter _interactive-checkbox__choice-letter_cjbh9b'> ANSWER A </span>
</div>
<span class='course-player__interactive-checkbox__choice-text _interactive-checkbox__choice-text_cjbh9b'> The product's impact on customer satisfaction. </span>
<span class='course-player__interactive-checkbox__choice-answered _interactive-checkbox__choice-answered_cjbh9b'>
<i class='toga-icon toga-icon-circle-fill-check _interactive-checkbox__choice-icon_cjbh9b'> </i>
</span>
</div>
【问题讨论】: