0
votes

Thank you in advance for any assistance. 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]"

Any advice would be much appreciated!

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

1

1 Answers

-3
votes

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.