I'm working on a project and I'm trying to get lxml to pull stock data from separate tables on separate web pages. When I run my program trying to print the values I'm trying to pull I get empty brackets
('Cash_and_short_term_investments:', []) ('EPSNextYear:', []) Here is a look at the way I am calling this:
#the url at this point is http://finviz.com/quote.ashx?t=RAIL confirmed with print statement url = driver.current_url page2 = requests.get(url) tree2 = html.fromstring(page2.content) EPSNextYear = tree2.xpath('/html/body/table[3]/tr[1]/td/table/tr[7]/td/table/tr[2]/td[6]/b') #Original XPath:/html/body/table[3]/tbody/tr[1]/td/table/tbody/tr[7]/td/table/tbody/tr[2]/td[6]/b print ('EPSNextYear:', EPSNextYear) and:
#the url at this point is https://www.google.com/finance?q=NASDAQ%3ARAIL&fstype=ii&ei=hGwhWNHVPOW7iwLMiIfIDA I've confirmed this with a print url = driver.current_url page3 = requests.get(url) tree3 = html.fromstring(page3.content) Cash_and_Short_Term_Investments = tree3.xpath('//*[@id="fs-table"]/tr[3]/td[2]/text()') print('Cash_and_short_term_investments:', Cash_and_Short_Term_Investments) I have removed the tbody from the XPath like some similar questions have suggested. Any help or suggestions would be greatly appreciated, thanks!