A Cloudflare Worker that fetches and caches current gold prices from goldprice.org using Puppeteer.
- Automated Price Fetching: Runs every 6 hours via cron triggers
- R2 Storage: Caches latest price with historical metadata
- On-Demand Updates: Fetches fresh data if cache is empty
- Puppeteer Integration: Uses Cloudflare Browser Workers for scraping
# Get current gold price
curl https://your-worker.workers.dev/
# Fetch from specific URL
curl https://your-worker.workers.dev/?url=https://goldprice.org/{
"price": "$2,345.67",
"source": "https://goldprice.org/",
"fetchedAt": "2025-10-08T12:00:00.000Z"
}GOLD_PRICE_ORG: Default gold price URLTARGET_URL: Alternative target URL
- Cloudflare Workers account
- R2 bucket named
misc - Browser binding enabled
Create a custom function using Apps Script:
- In your Google Sheet, go to Extensions → Apps Script
- Delete any existing code and paste this:
function GETGOLDPRICE() {
var url = "https://your-worker.workers.dev/";
var response = UrlFetchApp.fetch(url);
var data = JSON.parse(response.getContentText());
// Return just the price (removes commas and converts to number)
return parseFloat(data.price.replace(/,/g, ''));
}- Save the project (Ctrl/Cmd + S)
- Go back to your sheet and use in any cell
=GETGOLDPRICE()- returns just the price as a number