0

I am trying to import a table from a webpage into a google spreadsheet.

I have tried using the following two functions and both are giving me the error that the "imported content is empty".

=importhtml("http://financials.morningstar.com/ratios/r.html?t=AAPL","table",1)

And

=importxml("http://financials.morningstar.com/ratios/r.html?t=AAPL", "//*[@id='tab-profitability']/table[2]"

p.s. the imported data is for personal use only and will not be used against the websights policies.

Rubén
  • 34,714
  • 9
  • 70
  • 166
DJL
  • 9
  • 1
  • 2
  • I’m voting to close this question because the URL to be web scraped is broken and there is nothing for future readers to learn from this Q/A – Rubén Jan 02 '23 at 03:06

1 Answers1

-4

It's not possible with your url (http://financials.morningstar.com/ratios/r.html?t=AAPL). The command =importhtml() it's possible if the webpage has a html table.

I give you an example :

Example

In this URL : http://fr.wikipedia.org/wiki/Démographie_de_l'Inde In this webpage , you can see a table . The table is a html table

Code in the page :

 <table class="wikitable centre" style="text-align: center;">
<tr>
<th colspan="3" scope="col" width="60%">Évolution de la population</th>
</tr>
<tr>
<th>Année</th>
<th>Population</th>
<th><abbr title="Croissance démographique">%±</abbr></th>
</tr>
<tr>
<td>1951</td>
<td>361 088 000</td>
<td>—</td>
</tr>
<tr>
<td>1961</td>
<td>439 235 000</td>
<td>+ 21,6&#160;%</td>
</tr>

<!--  Others value -->

<td colspan="3" align="center"><small>Source&#160;: <a rel="nofollow" class="external autonumber" href="http://indiabudget.nic.in/es2006-07/chapt2007/tab97.pdf">[1]</a></small></td>
</tr>
</table>

In your Google Spreadsheet you can show data

=IMPORTHTML("http://fr.wikipedia.org/wiki/Démographie_de_l'Inde"; "table"; 


In this Webpage ( http://financials.morningstar.com/ratios/r.html?t=AAPL ), you don't have any html table so you can extract values.

Hann
  • 727
  • 3
  • 11
  • 22
  • 2
    in the link they mentioned I can see several HTML tables in the source code, for example...searching by: ....
    2005-092006-09
    Do you know if it's not working for a different reason? or why did you say that in that page there's not html table? Is the example above something different? Cheers!
    – mickael Sep 30 '15 at 22:04