You need the price, not the whole page
You found a product page with the exact price you need. You could scrape the entire page with =VISIT() and ask AI to find it. That works. But there is a faster way.
What if you could tell your spreadsheet "grab the element with this exact class name" and get back just the price? No AI processing. No extra steps. Just the raw data from the HTML.
That is what =GETSELECTOR() does. You give it a URL and a CSS selector. It returns exactly what matches. Nothing more.
=GETSELECTOR(A2, "span.price")Pulls the text content of every element matching span.price on the page at A2.
Five minutes of learning CSS selectors gives you precision control over what you scrape from any website. This guide shows you how to find selectors, write them, and use them in real scraping workflows.
What is a CSS selector?
CSS selectors are patterns that target specific HTML elements on a page. Browsers use them for styling. You can use them for scraping.
Every element on a webpage has a tag name (like div, span, or h1). Most also have classes and IDs that make them unique. A CSS selector is just a short string that describes which element you want.
Here are the four patterns you will use most:
Class selectors start with a dot. They match elements with a specific CSS class.
=GETSELECTOR(A2, ".product-title")Grabs every element with the class product-title. This is the most common selector you will use.
ID selectors start with a hash. They match one specific element (IDs are unique on a page).
=GETSELECTOR(A2, "#main-price")Grabs the single element with the ID main-price. Returns one result since IDs are unique per page.
Tag selectors use the element name directly. Good for grabbing all headings or all links.
=GETSELECTOR(A2, "h2")Pulls every H2 heading from the page. Same result as =GETH2() but using a raw selector.
Nested selectors combine patterns with a space to target elements inside other elements.
=GETSELECTOR(A2, "div.reviews span.rating")Finds span elements with the class rating, but only inside a div with the class reviews.
That is it. Four patterns cover 90% of what you will need.
You do not need to memorize these. The next section shows you how to copy the exact selector from your browser in three clicks.
How to find the right selector in 30 seconds
The browser does the hard work for you. Here is the exact process.
Open the page and right-click the element you want
Go to the webpage with your target data. Right-click on the specific text, price, or rating you want to scrape. Select Inspect (or Inspect Element in some browsers).
Find the element in the DevTools panel
The DevTools panel opens with the HTML element highlighted. Look at the tag name, classes, and IDs. You will see something like <span class="price-value">$49.99</span>.
The selector for this element is span.price-value. Tag name, dot, class name.
Test your selector
In the DevTools Console tab, type document.querySelectorAll("span.price-value") and press Enter. The browser shows you every matching element. If you see one result, your selector is specific enough. If you see ten, you might need a more targeted selector.
Paste it into your formula
=GETSELECTOR(A2, "span.price-value")Uses the selector you just found. The formula pulls the matching content directly into your cell.
That is the entire workflow. Find it in the browser, paste it into your formula.
You can try all of this on the free tier. No credit card needed. Each =GETSELECTOR() call uses 1 integration credit. The free tier includes 10 credits (one-time trial), so you have enough for ten test scrapes.
Example 1: Scrape product prices from an e-commerce page
Price monitoring is one of the best uses for CSS selector scraping. Prices live in consistent HTML structures across product pages on the same site.
Find the price selector
Go to a product page. Right-click the price and inspect it. You might see something like <span class="a-price-whole">29</span> or <div class="price-box">$49.99</div>.
Write down the selector. For this example: span.a-price-whole.
Set up your sheet
Put product page URLs in column A. Add the formula in column B:
=GETSELECTOR(A2, "span.a-price-whole")Pulls the price from each product page. Drag this formula down column B for all your URLs.
Clean the output
Prices sometimes come back with extra characters. Use native Sheets formulas to clean them:
=VALUE(SUBSTITUTE(SUBSTITUTE(B2, "$", ""), ",", ""))Strips the dollar sign and commas, then converts the text to a number. Now you can sort, average, and chart your prices.
Once you have prices as numbers, you can build alerts. A simple =IF(B2<C2, "Price dropped!", "") flags changes instantly. For a full price tracking setup with charts and automation, see the price monitoring dashboard guide.
Example 2: Extract review ratings and counts
Product reviews are gold for competitive research. And they almost always follow a consistent HTML pattern within a single site.
=GETSELECTOR(A2, "span.review-score")Pulls the star rating from a product page. The exact class name depends on the site.
=GETSELECTOR(A2, "span.review-count")Grabs the number of reviews. Combine with the rating to get a fuller picture of product sentiment.
You can pull both pieces into adjacent columns and run analysis on them:
=AITEXT("This product has a rating of "&B2&" with "&C2&" reviews. Is this above or below average for this category? Give a one-sentence assessment.", "")Feeds your scraped data into AI for quick competitive analysis.
Review data is often loaded dynamically with JavaScript. If =GETSELECTOR() returns empty results, the reviews might load after the initial page render. Try =VISIT() combined with =AITEXT() as a fallback. The VISIT formula handles JavaScript-rendered pages.
Example 3: Pull job listings from a careers page
Many companies list open positions on a structured careers page. Job titles, departments, and locations usually sit in repeating HTML elements with consistent class names.
=GETSELECTOR(A2, "h3.job-title")Extracts every job title from a company careers page. Each matching element becomes a separate result.
=GETSELECTOR(A2, "span.job-location")Pulls the location for each listed position.
This is great for sales prospecting. A company with 15 open engineering roles is probably growing fast. That is useful context for outreach.
You can scale this across multiple companies. Put their careers page URLs in column A and drag your formulas down. In five minutes you have a competitive hiring landscape spreadsheet.
Example 4: Grab stock or financial data
Financial data websites tend to have very structured HTML. Stock prices, market caps, and P/E ratios all sit in clearly labeled elements.
=GETSELECTOR(A2, "fin-streamer[data-field=regularMarketPrice]")Uses an attribute selector to grab the current stock price. Attribute selectors match elements by their HTML attributes.
This example introduces attribute selectors. Instead of matching by class or ID, you match by any HTML attribute. The syntax is tag[attribute=value].
=GETSELECTOR(A2, "td[data-test=MARKET_CAP-value]")Pulls the market cap value using a data attribute. Financial sites love data attributes for labeling their data points.
Attribute selectors are your best friend on data-heavy sites. Financial portals, real estate listings, and government databases all use data attributes to label their content. Look for attributes that start with data- in the DevTools inspector.
Example 5: Monitor competitor features and pricing pages
Competitors change their pricing pages and feature lists more often than you think. CSS selectors let you track those changes from a spreadsheet.
=GETSELECTOR(A2, "div.pricing-card h3")Grabs plan names from a pricing page. Most SaaS sites structure their pricing in card layouts.
=GETSELECTOR(A2, "div.pricing-card .price")Pulls the price for each plan. Pair this with plan names to build a competitor pricing comparison sheet.
For feature lists:
=GETSELECTOR(A2, "ul.feature-list li")Extracts every feature bullet point from a competitor page.
Set this up once and re-run it weekly. When a competitor adds a feature or changes a price, your spreadsheet catches it.
Advanced selectors for tricky pages
Sometimes the basic patterns are not enough. Here are three advanced techniques for tougher scraping jobs.
The nth-child selector
When a page has multiple similar elements and you only want one:
=GETSELECTOR(A2, "table.data tr:nth-child(3) td")Grabs the cells from the third row of a data table. Change the number to target any row.
The :nth-child(n) pseudo-class lets you pick a specific item from a list. Use :nth-child(1) for the first item, :nth-child(2) for the second, and so on.
Combining multiple classes
Some elements have more than one class. Chain them together without spaces:
=GETSELECTOR(A2, "div.card.featured.active")Matches a div that has all three classes: card, featured, and active. Each dot adds another required class.
Child combinators
A > symbol targets direct children only (not nested deeper):
=GETSELECTOR(A2, "ul.nav > li > a")Grabs only top-level navigation links. Skips any links nested inside dropdown menus.
Common pitfalls and how to fix them
Dynamic class names
Some modern websites generate random class names like css-1a2b3c or _3xKf2. These change every time the site rebuilds. Your selector breaks.
The fix: Look for stable attributes instead. Data attributes (data-testid, data-product-id), ARIA labels (aria-label), or structural selectors (main > div:first-child h2) are more reliable than generated class names.
=GETSELECTOR(A2, "[data-testid=product-price]")Targets elements by data-testid, which developers add for testing and rarely change.
Nested or shadow DOM elements
Some components (especially on React or Angular sites) use shadow DOM. Standard CSS selectors cannot reach inside shadow DOM boundaries.
The fix: Use =VISIT() with =AITEXT() instead. The VISIT formula renders the full page (including shadow DOM content) and the AI can extract what you need from the text.
=AITEXT("Extract the product price from this page content. Return only the number.", VISIT(A2))Fallback approach when CSS selectors cannot reach the data. VISIT renders the page fully, then AI finds the price in the text.
Too many results
Your selector matches 50 elements when you only wanted 1. The page has the same class name on multiple elements.
The fix: Make your selector more specific. Add a parent element, use :nth-child(), or combine multiple classes. Test in your browser console first with document.querySelectorAll("your-selector") to check the count before putting it in your formula.
For a broader look at troubleshooting web scraping issues, see the complete web scraping guide.
When to use GETSELECTOR vs. other scraping formulas
Each scraping formula has a sweet spot. Here is when to reach for each one.
| Situation | Best formula | Why |
|---|---|---|
| You know the exact CSS selector | =GETSELECTOR() | Fastest, most precise |
| You need the full page text | =VISIT() | Returns up to 50,000 characters |
| You want all headings | =GETH1(), =GETH2(), =GETHEADINGS() | Purpose-built, no selector needed |
| You need meta tags | =GETMETATITLE(), =GETMETADESCRIPTION() | One call, one result |
| The data is behind JavaScript | =VISIT() + =AITEXT() | VISIT handles JS rendering |
| You need data from Google Maps, Amazon, etc. | AI Chat sidebar integrations | Structured scrapers for complex sites |
=GETSELECTOR() is your go-to when you can identify the HTML element. It is faster than using =VISIT() plus =AITEXT() because it skips the AI processing step entirely. And it costs 1 integration credit per call, same as every other scraping formula.
For scraping images specifically, =GETSELECTOR() can target img tags and pull src attributes. See the image scraping guide for full walkthroughs.
Build a complete scraping workflow
Here is a real workflow that combines CSS selectors with AI formulas. You will build a competitor product research sheet from scratch.
Find product page URLs
=SERP("best wireless headphones 2026")Pulls search results for your product category. Extract the product page URLs from the results.
Copy 10-15 product page URLs into column A.
Scrape product names
Inspect one product page to find the name selector. Then apply it across all URLs:
=GETSELECTOR(A2, "h1.product-name")Grabs the product name from each page. Put in B2 and drag down.
Scrape prices
=GETSELECTOR(A2, "span.price")Pulls the price from each product page. Put in C2 and drag down.
Scrape ratings
=GETSELECTOR(A2, "span.rating-value")Extracts the star rating. Put in D2 and drag down.
Add AI analysis
=AITEXT("This product costs "&C2&" and has a "&D2&" star rating. Write a one-sentence competitive positioning summary.", "")Turns raw scraped data into actionable competitive insights.
You now have a product research sheet that took ten minutes to build. Updating it is even faster. Just re-run the formulas when you want fresh data.
CSS selector cheat sheet
Keep this table handy when you are building selectors.
| Selector | What it matches | Example |
|---|---|---|
.class | Elements with that class | .price, .product-title |
#id | The element with that ID | #main-content, #header |
tag | All elements of that type | h1, p, img |
tag.class | Tag with a specific class | span.rating, div.card |
.a .b | .b nested inside .a | .reviews .star-count |
.a > .b | .b as a direct child of .a | ul.menu > li |
[attr=val] | Element with that attribute value | [data-testid=price] |
:nth-child(n) | The nth element among siblings | tr:nth-child(2) |
.a.b | Element with both classes | .card.featured |
Start scraping with selectors
CSS selectors give you surgical control over what data comes back from a webpage. You point at an element. You get that element. No guesswork.
The formula is simple. The hard part (finding the right selector) takes 30 seconds in your browser DevTools. And you can test it before you ever put it in a spreadsheet.
=GETSELECTOR("https://example.com", "h1")Try this now. Replace the URL with any page and the selector with any element you want to grab.
You can try all of this on the free tier. No credit card needed. You get 10 integration credits (one-time trial), enough for 10 scrapes to see how selectors fit your workflow.
Install SheetMagic free from the Google Workspace Marketplace and scrape your first element in under a minute.
More web scraping guides: Complete scraping guide | Extract content | Image scraping | Price monitoring | Getting started

