P
P
phil15142022-03-09 17:54:46
Google Apps Script
phil1514, 2022-03-09 17:54:46

How to download the exchange rate from the Tinkoff website?

It is required to load from the page https://www.tinkoff.ru/about/exchange/ the exchange rate of rubles for dollars (about 140 now) in google tables.
As far as I understand, this can be done using IMPORTXML(" https://www.tinkoff.ru/about/exchange "; "/html/body/div[1]/div/div/div[2]/div/div[ 3]/div[2]/div[3]")
But for some reason the formula doesn't produce anything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2022-03-09
@phil1514

It is simply not in the original HTML, it is obtained by the script
Look towards this request:

fetch("https://api.tinkoff.ru/v1/currency_rates?from=USD&to=RUB", {
  "headers": {
    "accept": "*/*",
    "accept-language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
    "content-type": "application/x-www-form-urlencoded",
    "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"99\", \"Google Chrome\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-site"
  },
  "referrer": "https://www.tinkoff.ru/",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": null,
  "method": "GET",
  "mode": "cors",
  "credentials": "omit"
});

In response:

{"trackingId":"WEE285K7UR","resultCode":"OK","payload":{"lastUpdate":{"milliseconds":1646839634102},"rates":[{"category":"C2CTransfers","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":111.25,"sell":138.75},{"category":"OPSRateGroup","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"DebitCardsTransfers","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferFrom10To100G13CO","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"CUTransfersPremium","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferBelow10G11","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"DepositPayments","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":111.25,"sell":138.75},{"category":"SMETransferAbove100","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferBelow10","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"CreditCardsOperations","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":111.25,"sell":138.75},{"category":"CUTransferAbove100","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"PrepaidCardsOperations","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":111.25,"sell":138.75},{"category":"SMETransferAbove100G13","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferFrom10To100G13","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferBelow10G12","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferFrom10To100G11","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferBelow10G13CO","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"CUTransferFrom10To100","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferAbove100G12","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferAbove100G13CO","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferAbove100G11","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"PrepaidCardsTransfers","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"DebitCardsOperations","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":111.25,"sell":138.75},{"category":"SavingAccountTransfers","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferFrom10To100G12","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"CUTransfersPro","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"CreditCardsTransfers","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferBelow10G13","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95},{"category":"SMETransferFrom10To100","fromCurrency":{"code":840,"name":"USD","strCode":"840"},"toCurrency":{"code":643,"name":"RUB","strCode":"643"},"buy":113.05,"sell":140.95}]}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question