Search code examples
google-apps-scriptgoogle-sheetsweb-scrapinggoogle-sheets-formula

IMPORTHTML not working for retrieving the table that shows the player rankings


I have used importhtml function for google sheets many times and successfully but sometimes I have had no luck in getting it to work.

I am doing this to help track some gaming performances in events.

I would like to retrieve the table that shows the player rankings that I have found on this web page.

Player Rankings

I have used =IMPORTHTML("https://volknn.ru/fire/#/FAME";"table";3), but i only get the tags like shown below.

How can this be dealt with?

№               "{{'POINTS_TO' | translate}} {{session.frontier.t/1000}}k 
({{session.globalpointsTank}})"     д           
{{$index + 1}}  {{user.name}}   {{user.position}}   {{user.points}} {{session.globalpointsTank - user.points}}  "{{user.battles > 0 ? user.battles : ""<"" + session.conds.battles}} ({{user.bt_clan}} 
{{'FOR_CLAN' | translate}})"    {{user.wr}} {{user.days}}   "{{multiplier && user.bt_clan >= session.conds.battles ? clan.reward * 
user.bonds : user.bonds}}"  

Solution

  • The =IMPORTHTML function won't work because the website loads the data dynamically so you should be using another method.

    A solution would be to use the IMPORTJSON library with Apps Script.

    You should be installing by going to Tools > Script Editor and add the ImportJSON.gs file. Now in your spreadsheet you can access the ImportJSON() function.

    Afterwards, you should just use the following formula in your Spreadsheet:

    =ImportJSON("https://volknn.ru/fire/classes/getclan.php?front=west&name=FAME&server=ru", "/users")
    

    The URL was obtained by using the Google Chrome Console and checking the Network Tab, filtering the requests by XHR and finding the request which inputs the data into the table.

    You can also check this link for more information:

    1. ImportJSON;

    2. IMPORTHTML.