【问题标题】:Google Spreadsheet ImportHTML and ImportXML: imported content is emptyGoogle 电子表格 ImportHTML 和 ImportXML:导入的内容为空
【发布时间】:2015-02-20 23:01:54
【问题描述】:

提前感谢您的帮助。我正在尝试将网页中的表格导入谷歌电子表格。

我尝试使用以下两个函数,但都给我“导入的内容为空”的错误。

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

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

任何建议将不胜感激!

附言导入的数据仅供个人使用,不会用于违反 websights 政策。

【问题讨论】:

    标签: import google-sheets


    【解决方案1】:

    您的网址 (http://financials.morningstar.com/ratios/r.html?t=AAPL) 不可能。 命令=importhtml() 如果网页有html表就可以了。

    我举个例子:

    示例

    在此网址中:http://fr.wikipedia.org/wiki/Démographie_de_l'Inde 在这个网页中,您可以看到一个表格。该表是一个html表

    页面中的代码:

     <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>
    

    在您的 Google 电子表格中,您可以显示数据

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


    在此网页 (http://financials.morningstar.com/ratios/r.html?t=AAPL) 中,您没有任何 html 表,因此您可以提取值。

    【讨论】:

    • 在他们提到的链接中,我可以在源代码中看到几个 HTML 表格,例如...搜索:....
      2005-09 2006-09
      你知道它是否因为其他原因而不起作用吗?或者你为什么说那个页面没有 html 表?上面的例子有什么不同吗?干杯!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多