1

I'm trying to extract data from a table into Google Sheets, from this webpage: http://www.moneycontrol.com/stocks/fno/marketstats/futures/gainers/homebody.php?opttopic=&optinst=allfut&sel_mth=1&sort_order=0

I've tried using "IMPORTHTML" and "IMPORTXML" both, however, they do not seem to work. Any suggestions would be greatly appreciated!

This is the error message that comes up on running both the queries:

Error Imported content is empty.

FYI this is what I typed into the spreadsheet:

=IMPORTHTML(" http://www.moneycontrol.com/stocks/fno/marketstats/futures/gainers/homebody.php?opttopic=&optinst=allfut&sel_mth=1&sort_order=0 ", "TABLE", 2)

The table is not dynamically created as it is available in the page source. Even changing the index of the IMPORTHTML function does not help. every index returns "Imported content is empty".

3
  • My guess is that importhtml fails because of a "form" placed inside of the table. Google Apps Script (UrlFetchApp) may be a way to get around the issue.
    – user135384
    Commented Apr 2, 2018 at 5:57
  • @SFTP I was using the same function for 1 week, and it worked perfectly. The error began today itself. There are other tables too, on the same page. None of them has a "form" placed inside, and still, the same error appears upon trying to import them. Also, can you guide me on how to use the UrlFetchApp to import tables? Commented Apr 2, 2018 at 7:06
  • @InderpartapCheema are you still seeking an answer for this? Commented Jun 21, 2018 at 9:24

1 Answer 1

1

When URL: http(s)://www.moneycontrol.com/stocks/fno/marketstats/futures/gainers/homebody.php?opttopic=&optinst=allfut&sel_mth=1&sort_order=0

opened in client (browser) following server side rendering of dynamic data are requested by browser:

 - send @   jquery-1.12.0.min.js:4 
 - ajax @   jquery-1.12.0.min.js:4
 - updaterss    @   jquery.webticker.js:39
 - (anonymous)  @   jquery.webticker.js:137
 - many more...

this is why you can not use IMPORTHTML or IMPORTXML to fetch Dynamic data as in this webpage.

How to check if Error: Imported Content is Empty is because of dynamic data?

  1. use a la carte rendering of web page in question like:

    =IMPORTXML("http://www.moneycontrol.com/stocks/fno/marketstats/futures/gainers/homebody.php?opttopic=&optinst=allfut&sel_mth=1&sort_order=0", "/")

    • "/" will force to fetch everything from URL, and there is nothing useful in this IMPORT XML/HTML for your need.
  2. Using the Chrome browser's INSPECT function displays all the client requests.

1
  • @user0 Please resubmit the edit. I didn't understand that the change had been introduced by someone (you!) and was not part of the original answer. Thanks.
    – jonsca
    Commented Aug 6, 2018 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.