Search code examples
htmlgoogle-sheetsweb-scrapinggoogle-sheets-formulaimport-table

googlesheets can't import expandable table


I can't import the second table of this site on my google sheets: https://www.wsj.com/market-data/quotes/AMZN/financials/annual/balance-sheet

(the table that show when you click on "Liabilities & Shareholders' Equity").

This is my code:

=IMPORTHTML("https://www.wsj.com/market-data/quotes/AMZN/financials/annual/balance-sheet", "table",2)

Solution

  • The table you want is not the 2nd table on the page, it is the 59th table.

    Check out the documentation for the IMPORTHTML function here: https://support.google.com/docs/answer/3093339?hl=en

    The last argument is which table on the page you want. When I inspected the HTML for the page, I found 115 <table> elements making up the HTML on the page.

    So, your code should look like this:

    =IMPORTHTML("https://www.wsj.com/market-data/quotes/AMZN/financials/annual/balance-sheet", "table",59)
    

    I just tested this in Google Sheets, and it did import the data.