【发布时间】:2017-09-25 03:27:17
【问题描述】:
我试图抓取的页面类似于下面的代码。 根据从一个 DIV 中抓取和验证的文本,我需要从以下 DIV 中抓取值。
我有正确的 XPath 来获取我需要验证的 DIV,但是,我不知道如何从相邻的 DIV 中获取文本?
<h3>TableWithColumnsAndRowsDIVstyle</h3>
<div class="row row-flex rowLine" style="padding: 2px 0;">
<div class="col-1 vcenter">
::before
<h4 style="white-space: nowrap;">
RowValueNameX
</h4>
</div>
<div class="col-2 vcenter text-right">
::before
<h4>
<b>RowValueX_ThatINeedToExtract</b>
</h4>
</div>
::after
</div>
<div class="row row-flex rowLine" style="padding: 2px 0;">
<div class="col-1 vcenter">
::before
<h4 style="white-space: nowrap;">
RowValueNameY
</h4>
</div>
<div class="col-2 vcenter text-right">
::before
<h4>
<b>RowValueY_ThatINeedToExtract</b>
</h4>
</div>
::after
</div>
<div class="row row-flex rowLine" style="padding: 2px 0;">
<div class="col-1 vcenter">
::before
<h4 style="white-space: nowrap;">
RowValueNameZ
</h4>
</div>
<div class="col-2 vcenter text-right">
::before
<h4>
<b>RowValueZ_ThatINeedToExtract</b>
</h4>
</div>
::after
</div>
我拥有的 XPath 看起来像这样
//*[contains(normalize-space(text()),"RowValueNameX")]
现在我需要得到这个文本
RowValueX_ThatINeedToExtract
【问题讨论】:
标签: xpath