如何使用selenium在两个跨距之间获取文本
<div style="display:inline">
<span style="margin-right:4px">£</span>
<input type="text" name="binPrice" id="binPrice" aria-describedby="err_binPrice" value="8.95" md="dt|DOUBLE||em|Please enter a Buy it now price.||vm|Please enter a valid Buy it now price." vld="1" maxlength="10" aria-required="true">
</div>
Python
driver.find_elements_by_xpath('//span[@style="margin-right:4px"]\span')
我想得到“£”
我是根据你的最新评论写的。 首先,xpath是错误的。xpath中有一个不必要的'\span'。 尝试使用:
其次,我注意到使用style属性不是一个好主意,因为可能有几个元素具有相同的样式。我建议使用input元素,因为它有一个ID。 所以就像:
这将更加有力。 希望这有帮助。你知道吗
相关问题 更多 >
编程相关推荐