Python Lxml - Returns Null List
I cannot figure out what is wrong with the XPATH when trying to extract a value from a webpage table. The method seems correct as I can extract the page title and other attributes,
Solution 1:
You should specify element name. If you don't want specify specific tag name, you can use *
:
print tree.xpath('//*[@id="financial"]/...')
^
UPDATE
In the html file (just the html before the rendering in the browser), there's no tbody tag. So you need to remove tbody
from the expression:
//*[@id="financial"]/table/tr/td[1]/table/tr[2]/td[1]/div[2]/text()
Alternative way using following-sibling
axis:
//div[text()="Total Assets"]/following-sibling::div/text()
Post a Comment for "Python Lxml - Returns Null List"