Level 3Pulling Data InReading, 6 min

IMPORTHTML, IMPORTXML and GOOGLEFINANCE

IMPORTRANGE reads other Google Sheets. Three more functions read the outside world.

IMPORTHTML(url, "table" or "list", index) pulls a table or list from a web page. The index counts tables from the top of the page, starting at 1:

=IMPORTHTML("https://beanthere.example.com/menu", "table", 1)

Can't tell which number you need? Try 1, 2, 3 until the right table appears.

IMPORTXML(url, xpath) pulls anything you can point at with an XPath, a little language for picking parts of a web page:

XPathReturns
//titlethe page title
//h1every top-level heading
//a/@hrefevery link address
//span[@class='price']the text of each span with class "price"
//meta[@name='description']/@contentthe meta description

Right-click the thing you want in Chrome, choose Inspect, and the highlighted HTML tells you the tag and class to use. SEO teams use IMPORTXML to audit titles and descriptions across a list of URLs: =MAP(A2:A20, LAMBDA(u, IMPORTXML(u, "//title"))).

GOOGLEFINANCE(ticker, attribute) returns market data:

=GOOGLEFINANCE("NASDAQ:GOOG", "price")
=GOOGLEFINANCE("NYSE:KO", "pe")
=GOOGLEFINANCE("CURRENCY:EURUSD")
=GOOGLEFINANCE("NASDAQ:GOOG", "close", DATE(2026,1,1), DATE(2026,3,31), "WEEKLY")

Other attributes include marketcap, changepct, high52 and volume. The history version spills a two-column table with Date and Close headers, ready to chart. The CURRENCY form is handy for converting ad spend in euros or pounds, with one caveat below.

Rules for outside data:

  • It isn't instant. IMPORTHTML and IMPORTXML refresh roughly every hour. GOOGLEFINANCE prices can lag by up to 20 minutes. Don't trade off them, and don't use live rates for numbers finance has to reconcile; finance books at a fixed rate on a set date.
  • Pages change. A redesign can move the table you were importing to position 2, or rename the class. Keep imports on their own tab so a break is easy to spot.
  • Not every page works. Sites that build content with JavaScript after loading, sit behind a login, or block bots return errors like "Could not fetch url".
  • Historical finance data stays in Sheets. Google doesn't let Apps Script or the Sheets API read GOOGLEFINANCE history.
  • CSV files have their own function: IMPORTDATA(url).

This practice grid can't reach the internet, so the next exercises simulate the outside file and pages. The formulas are exactly what you'd type in a real sheet.