Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:Xpath无法获取数字_Python_Xpath - Fatal编程技术网

Python:Xpath无法获取数字

Python:Xpath无法获取数字,python,xpath,Python,Xpath,我想在html中获得'89.34'的信息 <div class="MarketsTable-container-2b0AP KeyMetrics-table-Ow-Ln"> <table class="table-container two_columns MarketsTable-borderless-1FRfN MarketsTable-headerless-1ZF6D MarketsTable-condensed-2ragd"> <tbody>&

我想在html中获得'89.34'的信息

    <div class="MarketsTable-container-2b0AP KeyMetrics-table-Ow-Ln">
<table class="table-container two_columns MarketsTable-borderless-1FRfN MarketsTable-headerless-1ZF6D MarketsTable-condensed-2ragd">
<tbody><tr class="data"><th class="MarketsTable-label-_JI6s" cellPadding="1" cellSpacing="1" scope="row"><div class="TextLabel__text-label___3oCVw TextLabel__gray___1V4fk TextLabel__regular___2X0ym MarketsTable-label-_JI6s">P/E excl. Extra Items (Annual)</div></th>
<td class="MarketsTable-value-FP5ul" cellPadding="1" cellSpacing="1">
<span class="TextLabel__text-label___3oCVw TextLabel__black___2FN-Z TextLabel__regular___2X0ym digits MarketsTable-value-FP5ul">89.34</span></td></tr><tr class="data">

不包括额外项目的P/E(年度)
89.34
我尝试使用xpath('//div[contains(,“p/E include.Extra Items(TTM)”)]/following-sibling::td[1]/text()),但没有返回任何内容。 请告知。 url如下所示

尝试下面的xpath

//div[contains(., 'P/E incl. Extra Items (TTM)')]/../following-sibling::td[1]/span/text()
或者您可以使用parent::th

//div[contains(., 'P/E incl. Extra Items (TTM)')]/parent::th/following-sibling::td[1]/span/text()

您的html无效;请编辑这个问题。@JackFleeting,对不起,我可能不会复制整个html,但我把链接