1

I would like to get the info of '89.34' in the html

    <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">

I try xpath('//div[contains(., "P/E incl. Extra Items (TTM)")]/following-sibling::td[1]/text()')but return nothing. Please advise. The url is as below https://www.reuters.com/companies/AALI.JK/key-metrics

2
  • Your html is invalid; please edit the question. Commented Mar 2, 2020 at 3:08
  • @JackFleeting, sorry, I may not copy the whole html but I put the link Commented Mar 2, 2020 at 3:47

1 Answer 1

1

Try the below xpath.

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

or you can use parent::th

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

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.