| 📅 Updated May 2026 | ⏱ 10 min read | 📊 Google Sheets |
You’re manually copying data from a website into a spreadsheet — prices, stats, rankings, scores — and by the time you’ve finished, half of it has already changed. There’s a much better way. Google Sheets has built-in functions that pull live data from websites automatically and refresh on their own, no copy-pasting required.
Here’s how to pull live data from a website into Google Sheets using three methods — from a one-line formula to a custom script — so you can pick whichever fits your situation.
Before You Start
One important thing to understand upfront: these methods only work on publicly accessible pages. If a site requires a login, blocks bots in its robots.txt, or loads its content dynamically via JavaScript, these formulas will either return an error or fetch incomplete data. For JavaScript-heavy sites, Apps Script is your best option — more on that shortly.
Method 1
IMPORTHTML — Pull Tables and Lists Instantly
IMPORTHTML is the easiest starting point. It’s a built-in Google Sheets function that grabs an HTML table or list from any public webpage and drops the data directly into your cells. I use this constantly for pulling things like Wikipedia tables, sports standings, and financial data tables.
The syntax is:
=IMPORTHTML("URL", "table" or "list", index)
The three arguments: the URL of the page in quotes, the query type — either "table" or "list" — and an index number telling Sheets which table or list on the page to grab (1 = first, 2 = second, and so on).
Real example — Wikipedia table
To pull the first table from Wikipedia’s list of largest companies by revenue:
=IMPORTHTML("https://en.wikipedia.org/wiki/List_of_largest_companies_by_revenue","table",1)
Click an empty cell, paste that formula, and hit Enter. Sheets fetches the data and populates the cells automatically. It refreshes every time the sheet recalculates — typically every hour, or when you force a refresh by pressing Ctrl+Shift+F9.
Method 2
IMPORTXML — Target Any Specific Element on the Page
When you need something more precise than a whole table — a single price, a headline, a product name, or a specific data point — IMPORTXML is the tool. It uses XPath to pinpoint any element on a webpage and pull just that value into your sheet.
The syntax:
=IMPORTXML("URL", "xpath_query")
XPath sounds intimidating but you only need a few patterns in practice. Here are the most useful ones:
| What you want | XPath query |
|---|---|
| Page title | //title |
| All H1 headings | //h1 |
| All links (href values) | //a/@href |
| Element with specific class | //*[@class="price"] |
| Meta description | //meta[@name='description']/@content |
Finding the right XPath for any element
In Chrome, right-click the element on the page you want to target and choose Inspect. In the DevTools panel, right-click the highlighted HTML element → Copy → Copy XPath. Paste that directly as your second argument in IMPORTXML. This step trips up a lot of people — they try to guess the XPath manually when the browser will just give it to you.
Method 3
Google Apps Script — Full Control, Any Site
When IMPORTHTML and IMPORTXML aren’t enough — because the data is buried behind an API, a form, or dynamic JavaScript — Apps Script gives you a full scripting environment inside Google Sheets. You write a short JavaScript function, and it fetches, parses, and writes data exactly where you want it. It’s also the only method that lets you schedule automatic refreshes at a specific time interval.
| 1 | In your Google Sheet, go to Extensions → Apps Script. The script editor opens in a new tab. Delete any placeholder code already in the editor. |
| 2 | Paste this starter script, which fetches data from a URL and writes it to cell A1: |
function fetchWebData() {
var url = "https://example.com/data-page";
var response = UrlFetchApp.fetch(url);
var html = response.getContentText();
// Example: extract text between two markers
var start = html.indexOf('<span class="price">') + 22;
var end = html.indexOf('</span>', start);
var price = html.substring(start, end);
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.getRange("A1").setValue(price);
sheet.getRange("B1").setValue(new Date()); // timestamp
}
| 3 | Replace the URL and the extraction logic with your target site and the specific data you need. Click the Save button (floppy disk icon), then click Run. The first time you run it, Google will ask for permission to access external URLs — click Review permissions → Allow. |
| 4 | To schedule automatic refreshes, click the Triggers button (clock icon in the left sidebar). Click Add Trigger, set Function to fetchWebData, Event Source to Time-driven, and choose your interval — every hour, every 6 hours, daily, etc. Click Save. |
Pro Tips & Common Mistakes
|
🔄
IMPORTHTML Doesn’t Refresh Instantly Sheets caches IMPORTHTML results for up to an hour. To force a manual refresh now, press Ctrl+Shift+F9 (Windows) or Cmd+Shift+F9 (Mac). This recalculates all volatile functions in the sheet. 🧱
Lock Imported Data From Overwriting Your Work IMPORTHTML and IMPORTXML auto-expand into adjacent cells. If you put formulas or data next to an import range, they’ll get overwritten when the import refreshes. Always give imports their own dedicated sheet tab. 🌐
Wrap URLs in ENCODEURL for Special Characters If your URL contains query parameters (e.g. 📡
Use an API If One Exists Many sites offer free APIs (weather, sports, finance, etc.). Apps Script can call these using |
Live Data, Always Up to Date
Between IMPORTHTML, IMPORTXML, and Apps Script, almost any publicly available data on the web can flow into your Google Sheet automatically. Start with IMPORTHTML for tables — it takes literally one line. Move to IMPORTXML when you need precision targeting. And reach for Apps Script when you need scheduled updates or anything a formula can’t handle.
Once you’ve got live data flowing in, the next step most people find useful is connecting it to Google Looker Studio — Google’s free dashboarding tool — which reads directly from Sheets and turns your live data into charts and reports that update automatically.
If you’re importing financial or sports data specifically, it’s also worth looking at dedicated data providers like Alpha Vantage (stocks) or the SportsDB API — both have free tiers and work perfectly with Apps Script.
