7 min read
Also: =IMPORTXML, IMPORTXML function, Google Sheets IMPORTXML, ImportXML formula, IMPORTXML XPath, importxml google sheets
IMPORTXML
Quick answer
IMPORTXML is a Google Sheets function, =IMPORTXML(url, xpath_query), that downloads a page's raw HTML or XML and returns the nodes matching an XPath query. It cannot run JavaScript or log in, so when it shows an error, start with the "Could not fetch url" fix.
IMPORTXML is a Google Sheets function that fetches a URL from Google's servers and returns whatever an XPath query selects from the page, such as titles, prices or links. It reads only the raw HTML, so it cannot see content that JavaScript adds after the page loads.
Last verified
What people do with IMPORTXML
- Fix "Could not fetch url"
The site blocked Google's fetcher, the URL is wrong, or the page needs a login.
- Fix "Imported content is empty"
The XPath matched nothing in the raw HTML, usually because JavaScript renders the data.
- Test an XPath query before pasting it into IMPORTXML
Run //a/@href or //span[@class='price'] against your HTML and see what matches.
- Fix "Imported Xml content can not be parsed"
What makes a page unparseable for IMPORTXML and what to try instead.
- Check IMPORTXML limits and refresh rules
How often import functions refresh, size caps and the quotas behind them.
- Diagnose Could not fetch url vs Loading... step by step
How to tell which cause you have and when a real browser is the only fix.
- Scrape Amazon prices into Google Sheets with a real browser
For pages IMPORTXML cannot read because they render with JavaScript or block Google.
Key facts
| Made by | Google (a built-in Google Sheets function) |
|---|---|
| Syntax | IMPORTXML(url, xpath_query, [locale]) |
| Accepts | XML, HTML, CSV, TSV, RSS and Atom XML feeds |
| Query language | XPath, run against the raw HTML the server returns (no JavaScript is executed) |
| Refresh | Google checks the source for updates hourly while the spreadsheet is open |
| Where it runs | On Google's servers, not in your browser, so it cannot use your cookies or logins |
What is IMPORTXML?
IMPORTXML is a built-in Google Sheets function that downloads a web page or XML document and pulls values out of it with an XPath query. Type =IMPORTXML("https://example.com", "//h1") into a cell and Sheets fills it with the text of every <h1> on that page. Because it needs no code, no add-on and no API key, it is usually the first scraping tool people try, and the first one they hit the limits of.
Google documents the function in the Google Docs Editors Help center. Its full signature is IMPORTXML(url, xpath_query, [locale]):
https://). It must be in quotes or come from a cell reference.//a/@href for every link or //span[@class='price'] for elements with that exact class.en_US, used when parsing numbers and dates. If omitted, the spreadsheet's locale is used.When the query matches several nodes, the results spill down a column. When a node has children, they can spill across columns as well.
How IMPORTXML actually fetches a page
The request does not come from your computer. Google's servers fetch the URL, parse the response and send the matched values back to your sheet. That has three consequences that explain most of the confusion around the function:
Google's help center says import functions check the source for updates hourly while the document is open. Reopening the sheet or pressing refresh does not force a new fetch; deleting and re-entering the formula does. That makes IMPORTXML a poor fit for anything that needs minute-by-minute freshness.
What people use IMPORTXML for
//a/@href.If the data you want is in a plain HTML <table> or <ul>, IMPORTHTML is simpler because it needs no XPath.
Common IMPORTXML errors
tbody the browser inserted.Before blaming the formula, test the expression against the page's raw HTML. The XPath tester can load a URL the same way a server-side fetcher does and show which nodes match.
IMPORTXML and automation
IMPORTXML is a good tool for a handful of static pages and a poor one for anything else. It cannot click, paginate, sign in, wait for JavaScript, or run on a schedule you control, and it fails silently when a site changes its markup. Teams usually outgrow it in one of three directions: a script with Google Apps Script and UrlFetchApp (which has the same no-JavaScript limitation), a code-based scraper, or a real browser.
A browser-based scraper differs in kind, not degree. It loads the page in Chromium, runs its JavaScript, and then extracts from the rendered DOM, which is why a selector that works in DevTools also works there. See how to scrape dynamic websites for the difference in practice.
In Autonoly, extraction runs in a real Chromium browser (Playwright-based), so JavaScript-rendered content is present. The data extraction step accepts the same XPath or CSS selector you would use in IMPORTXML, list steps can follow a Next button, and results are written to a sheet through the native Google Sheets integration on a schedule you set. It does not use proxies or rotate IPs, so a site that blocks automated traffic outright may still block it; when a CAPTCHA it cannot solve appears, you can take over the browser. The walkthrough in scraping a website to Google Sheets compares the two approaches end to end.
Why It Matters
IMPORTXML is the most common way people first pull web data into a spreadsheet, and its failure modes (no JavaScript, no logins, Google's servers doing the fetching, hourly refresh) explain why so many sheet-based scrapers break. Knowing those limits tells you when a formula is enough and when you need a real browser.
How Autonoly Solves It
Autonoly loads pages in a real Chromium browser, so content rendered by JavaScript is there to extract. You can reuse the XPath or CSS selector from your IMPORTXML formula in a data extraction step, follow pagination, and write rows to Google Sheets through the native integration on a schedule. It does not provide proxies or IP rotation, and sites that block automation can still block it.
Learn moreExamples
Using =IMPORTXML(A2, "//title") down a column of URLs to collect the page title of every page in an SEO audit
Pulling the price from a server-rendered product page with =IMPORTXML(url, "//span[@itemprop='price']/@content")
Replacing an IMPORTXML formula that returns 'Imported content is empty' on a JavaScript-rendered listing page with a scheduled browser workflow that extracts the same fields into Google Sheets
Frequently Asked Questions
Why does IMPORTXML return 'Imported content is empty'?
The fetch succeeded but your XPath matched nothing in the raw HTML. Usually the content is added by JavaScript after load, so it is not in what Google's servers downloaded. Check the page with view-source: or curl. If the data is missing there, no XPath will find it and you need a tool that renders the page in a browser.
Why does IMPORTXML say 'Could not fetch url'?
Google's servers could not get a usable response. Common causes are the site blocking Google's fetcher or data-center IPs, a login wall, a malformed or unquoted URL, a missing https:// prefix, or a server error. Test the URL in a private window and check whether the site blocks automated requests.
How often does IMPORTXML refresh?
Google's help center says import functions check the source for updates hourly while the spreadsheet is open. Reloading the sheet does not force a fetch. Deleting and re-entering the formula does. For a fixed schedule, people use an Apps Script time-driven trigger or move to a scheduled scraper.
Can IMPORTXML scrape pages that need a login?
No. The request is made by Google's servers without your cookies or session, so it only sees what an anonymous visitor would see. Pages behind a login need a browser that is signed in, or the site's own API.
Does IMPORTXML work with JavaScript-rendered sites?
No. It parses the HTML the server returns and never runs scripts. Single-page apps, infinite-scroll lists and prices loaded by an API call after page load are invisible to it. Sometimes the data is embedded as JSON in a script tag, which IMPORTXML can occasionally reach; otherwise use a browser-based scraper.
What is the difference between IMPORTXML and IMPORTHTML?
IMPORTHTML imports a whole HTML table or list by its position on the page and needs no XPath. IMPORTXML runs any XPath query, so it can pick individual elements or attributes. Both fetch the raw HTML from Google's servers and share the same limitations.
Further reading
Related terms, automations and guides
Where this concept shows up in practice.
Stop reading about automation.
Start automating.
Describe what you need in plain English. Autonoly's AI agent builds and runs the automation for you — no code required.