How to turn website data into an embed?
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

E.g. if I wanted to grab one specific HTML element from a website like the price of bitcoin from coindesk, how could I get it into an embeddable link that resolves to just the plain text number?

awarded to radosinsky

Crowdsource coding tasks.

1 Solution

Winning solution

Hello Daniel,

you can fetch the data from an API, if the website provides it.

CoinDesk has public Bitcoin Price Index API, which will return Bitcoin Price in JSON format.

Here's simple JS to get the price and update every 60 seconds:

const btcEl = document.getElementById('btc');

function getBitcoinPrice() {
  fetch('https://api.coindesk.com/v1/bpi/currentprice.json')
  .then(response => {
    return response.json();
  })
  .then(data => {
    btcEl.innerText = `$${data.bpi.USD.rate}`;
    setTimeout(getBitcoinPrice, 60000);
  });
}

getBitcoinPrice();

Then add this HTML anywhere on your page to show the bitcoin price:

<div id="btc"></div>

Here's a demo on Replit: https://replit.com/@radosinsky/CoindeskBitcoinPriceIndex

Let me know if this solves your problem or if there's anything else I can help you with. Thanks!