Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8924143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:19:50+00:00 2026-06-15T07:19:50+00:00

EDIT: I have provided the EXACT source code I’m using to try to figure

  • 0

EDIT: I have provided the EXACT source code I’m using to try to figure out this issue.

I’m trying to extract the data on “total assets” from Yahoo Finance using Python 2.7 and lxml. An example of a page I’m trying to extract this information from is http://finance.yahoo.com/q/bs?s=FAST+Balance+Sheet&annual .

I’ve already successfully extracted the data on “total assets” from Smartmoney. An example of a Smartmoney page I’m able to parse is http://www.smartmoney.com/quote/FAST/?story=financials&timewindow=1&opt=YB&isFinprint=1&framework.view=smi_emptyView .

Here is a special test script I set up to work on this issue:

    import urllib
    import lxml
    import lxml.html 

    url_local1 = "http://www.smartmoney.com/quote/FAST/?story=financials&timewindow=1&opt=YB&isFinprint=1&framework.view=smi_emptyView" 
    result1 = urllib.urlopen(url_local1)
    element_html1 = result1.read()
    doc1 = lxml.html.document_fromstring (element_html1)
    list_row1 = doc1.xpath(u'.//th[div[text()="Total Assets"]]/following-sibling::td/text()')
    print list_row1

    url_local2 = "http://finance.yahoo.com/q/bs?s=FAST" 
    result2 = urllib.urlopen(url_local2)
    element_html2 = result2.read()
    doc2 = lxml.html.document_fromstring (element_html2)
    list_row2 = doc2.xpath(u'.//td[strong[text()="Total Assets"]]/following-sibling::td/strong/text()')
    print list_row2

I’m able to get the row of data on total assets from the Smartmoney page, but I get just an empty list when I try to parse the Yahoo Finance page.

The source code of the table row on the Smartmoney page is:

    <tr class="odd bold">
<th><div style='font-weight:bold'>Total Assets</div></th>
<td>  1,684,948</td>
<td>  1,468,283</td>                                
<td>  1,327,358</td>                                
<td>  1,304,149</td>                                    
<td>  1,163,061</td>
    </tr>

The source code of the table row on the Yahoo page is:

    <tr>
<td colspan="2"><strong>Total Assets</strong></td>
<td align="right"><strong>1,684,948&nbsp;&nbsp;</strong></td>
<td align="right"><strong>1,468,283&nbsp;&nbsp;</strong></td>
<td align="right"><strong>1,327,358&nbsp;&nbsp;</strong></td>
    </tr>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:19:52+00:00Added an answer on June 15, 2026 at 7:19 am

    Contains syntax errors, should be td/strong/text() at the end, plus you have a trailing ]. I’d say that the correct query would be:

    xpath('//td[strong[text()="Total Assets"]]/following-sibling::td/strong/text()')
    

    Result:

    >>> tree.xpath('//td[strong[text()="Total Assets"]]/following-sibling::td/strong/text()')
    [u'1,684,948\xa0\xa0', u'1,468,283\xa0\xa0', u'1,327,358\xa0\xa0']
    

    In the original page the “Total Assets” <strong> container has whitespace and linebreaks. Use the additional normalize-space function on the text() result like so:

    xpath('//td[strong[normalize-space(text())="Total Assets"]]/following-sibling::td/strong/text()')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT I have finally figured out the problem i have been having on my
EDIT i have something like this in a file: imagecolor=0 arrayimagecolorcopy=0 arrayimagecolorcopy3d=0 when i
EDIT: I have realized the source of my problem. I only have count information
I have the following code (almost an exact copy of the Chat server example
I'm trying to gzip some data using Node.js... Specifically, I have data in 'buf'
EDIT: With the code below now, I am unsure on how to print out
I have provided a screenshot of my CredentialProvider window. In this window everything is
When I go to the edit_user_registration_path provided by Devise I have fields such as
EDIT: I have fixed all but two warnings now, so thank you all for
EDIT: I have edited my post... Working on a project (c#), I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.