简体   繁体   English

ImportHTML Google电子表格

[英]ImportHTML Google Spreadsheet

=ImportHtml("http://www.moneycontrol.com/financials/ranbaxylabs/consolidated-profit-loss/RL","table",5)

The above formula presents me with a nice table (profit and loss st) for ranbaxylabs for the years Dec 12 to Dec 08, however if you goto the link within you will notice that the table has a link as "Previous year" which gives same information for Dec 07 to Dec 04, where the url link is same. 上面的公式为我提供了一个适用于ranbaxylabs的12月12日至12月08年的漂亮表格(损益表),但是,如果您转到其中的链接,您会注意到该表格具有“上一年”链接, 12月7日至12月04日的信息,其中url链接相同。

Is there any way I can get this table "Dec 07 to Dec 04" in GSheet, by ImportHTML or some GAS script? 有什么方法可以通过ImportHTML或某些GAS脚本在GSheet中获取此表“ Dec 07 to Dec 04”?

You need to POST the parameters to get the data of Dec 07 to Dec 04. 您需要发布参数以获取Dec 07到Dec 04的数据。

Here is the GAS code, then you need to do some work with the response content to adjust it to your needs. 这是GAS代码,然后您需要对响应内容进行一些调整以使其适应您的需求。

function post() {
    var options = {
        "method" : "post",
        "payload": {
            "nav": "next",
            "type": "profit_cons",
            "sc_did": "RL",
            "start_year": 201212,
            "end_year": 200812,
            "max_year": 201212
        }
    };

    var response = UrlFetchApp.fetch("http://www.moneycontrol.com/financials/ranbaxylabs/consolidated-profit-loss/RL", options);

    Logger.log(response.getContentText());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM