我试图找到XPath来获取以下网站的5个值:https://plataforma.penserico.com/dashboard/cp.pr?e=TRPL4
我想要值7,59
2,04
1,81
7,60
7,59
对于第一个值,我尝试了此命令,但得到了#N / A:
=IMPORTXML("https://plataforma.penserico.com/dashboard/cp.pr?e=TRPL4";"//*[@id='j_idt104:0:j_idt109:1:chartPanel0']/div/span[1]")
HTML如下:
<span id="j_idt104:0:j_idt109:1:chartPanel0">
<div class="c--anim-btn" style="color: #5DADE2;">
<span class="c-anim-btn">
7,59
</span>
<span>
<div style="font-size: 12px !important;">
<div style="width: 90%; left: 5%; position:relative;line-height:2em;white-space: nowrap;">
<div style="width:50%;float:left"><label class="idtri">1T:</label>2,04</div>
<div style="width:50%;float:right"><label class="idtri">2T:</label>1,81</div>
</div>
<div style="width: 90%; left: 5%; position:relative;line-height:2em;white-space: nowrap;">
<div style="width:50%;float:left"><label class="idtri">3T:</label>7,60</div>
<div style="width:50%;float:right"><label class="idtri">4T:</label>7,59</div>
</div>
</div>
</span>
</div></span>
要获取我想要的值的第二个参数是什么? 谢谢
答案 0 :(得分:0)
您必须使用以下命令修复XPath以获得值:
//tr[.//span[.='P/L']]/td[2]//text()[parent::span[@class='c-anim-btn'] or parent::div][normalize-space()]
输出(C4中的公式):
编辑:单个XPath:
//tr[.//span[.='P/L']]/td[2]//text()[parent::span[@class='c-anim-btn']]
(//tr[.//span[.='P/L']]/td[2]//text()[parent::div][normalize-space()])[1]
(//tr[.//span[.='P/L']]/td[2]//text()[parent::div][normalize-space()])[2]
(//tr[.//span[.='P/L']]/td[2]//text()[parent::div][normalize-space()])[3]
(//tr[.//span[.='P/L']]/td[2]//text()[parent::div][normalize-space()])[4]