Google apps script – Importing data on website using ImportXML – Stack Overflow

0

pro debank

Importing data on website using ImportXML

Trying to import the balance on this website https://debank.com/profile/0x4e2a7d0e465d8d38aa5a1852d438e60b5832c1b4 The function im using is =IMPORTXML(“https://debank.com/profile/0x4e2a7d0e465d8d38aa5a1852d438e60b5832c1b4″,”/html/body/div[1]/div/div[2]/div[1]/div[2]/div/div[1]/div[2]”) but then i get a error saying Error Imported content is empty.

  • google-apps-script
  • google-sheets
  • web-scraping
  • google-sheets-formula

35.5k 9 9 gold badges 72 72 silver badges 170 170 bronze badges
asked Apr 22, 2022 at 20:08
25 5 5 bronze badges

2 Answers 2

google sheet import formula does not support the scrapping of javascript elements

answered Apr 22, 2022 at 20:18
126k 12 12 gold badges 72 72 silver badges 131 131 bronze badges

Alternatively, you can use debank’s own API and use this custom function:

Custom Function:

function getTotalBalance(user_id) < // replace key if you created your own account var key = 'cee6f36d707cf3dfb48e8d857408ef14ec707efa'; var url_balance = `https://pro-openapi.debank.com/v1/user/total_balance?id=$`; var params = < 'muteHttpExceptions': true, 'headers': < 'accept': 'application/json', 'AccessKey': key >>; return JSON.parse(UrlFetchApp.fetch(url_balance, params).getContentText()).total_usd_value; > 

Formula:

=getTotalBalance("0x4e2a7d0e465d8d38aa5a1852d438e60b5832c1b4", B1) 

Where the parameters are the user_id and B1 is a checkbox that would refresh the total balance if toggled.

Output:

Note:

  • Simply go to https://open.debank.com/ and register an email to get 10000 units for free.
  • Every balance fetch (toggle on checkbox) will cost you 150 units.
  • If your units get exhausted, you can register another mail and use its new key if you dont want to spend money, or pay for additional units if you want.
  • You can use my key until it is exhausted. Note that the custom function won’t automatically refresh, but you can use the checkbox method to refresh the value, or install a time trigger to refresh it on a specific time (I recommend using the checkbox method above since doing it on trigger and refresh it on intervals might exhaust your units faster than refreshing it manually when needed)

Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *