Skip to content

The =SCRAPE() formula

WebToSheets gives you a single function for pulling data into your sheet. It takes just two arguments, and this page documents everything they accept.

Syntax

At its simplest, you call =SCRAPE() with a URL and a selector:

=SCRAPE(url, "selector")          one selector
=SCRAPE(url, "sel1,sel2,sel3")    several — results fill adjacent cells
  • url is the full page URL, in quotes. Be sure to include https://.
  • selector is one or more selectors, comma-separated, describing what you would like to extract.
info
The formula takes exactly these two arguments. There is no third options argument. Country, JavaScript rendering, and caching are all handled automatically on our servers.

Passing multiple selectors

Sometimes you would like to extract several things at once. When you pass a comma-separated list, each selector becomes its own column, left to right, starting from the cell you typed the formula in.

For example, you may pull a blog page's main heading and its subheadings side by side:

=SCRAPE("https://example.com/blog", "h1,h2")

WebToSheets will "spill" the results into adjacent cells. When one selector returns more rows than another, the shorter columns are padded with blanks so everything stays aligned:

h1
h2
Main heading
First subheading
Second subheading

The /N index

Occasionally a selector returns a whole list when you only want one item from it. For these selectors, you may append a /N suffix to grab the Nth item (1-based), which works on the generic table selector and on the image selectors of product pages:

=SCRAPE("https://example.com", "table/2")     the 2nd table on the page
=SCRAPE("https://www.amazon.com/dp/B0D1XD1ZV3", "image/1")   the first product image

On search-result pages (eBay, Walmart, Google), each selector already returns a whole column of results. You may append /N to pull a single row instead.

Two kinds of selector

WebToSheets understands two selector forms, and you may pick whichever fits the page:

  • Named selectors are friendly keywords like title, price, or emails. The generic ones work on any website, and richer sets exist for supported platforms.
  • XPath is any expression starting with /, giving you pinpoint targeting when no named selector fits.
warning

CSS selectors are not supported

Unlike some tools, =SCRAPE() does not accept raw CSS selectors (for example .price > span). You should use a named selector or an XPath expression instead.

Finding the right selector

  1. Try a named selector first. Check the page for your platform, since most needs (name, price, rating, image) already have a keyword.
  2. On any other site, start broad. title, h1, p, table/1, emails, or linkUrls cover most pages with no inspection at all.
  3. Need a precise element? Build an XPath. In your browser, right-click the element → Inspect, then right-click the highlighted node in DevTools → Copy → Copy XPath. Paste it as your selector.

Pasted into the formula, an XPath selector looks like this:

=SCRAPE("https://example.com", "//span[class=""='price']")
lightbulb
A wrong selector returns an empty result and costs no credit, so feel free to experiment until a formula returns what you expect.

Still stuck?

We usually reply within 24 hours on business days.

Contact support arrow_forward