LightCube Data Extractor Add to Chrome ↗

How to find the right CSS selector for scraping

Right-click the element in Chrome, choose Inspect, and look for a stable class or attribute shared by all the items you want, such as class="product-title". Use that as .product-title. Avoid auto-generated class names and long copied selector paths, which match only one element or break when the site updates.

Do this in one click with LightCube Data Extractor, a free Chrome extension. No account needed.

Add to Chrome, free ↗

Step by step

  1. Right-click one example of the data and choose Inspect.
  2. In the Elements panel, look at the highlighted tag and its class or data attributes.
  3. Check another example to confirm it shares the same class.
  4. Test in the Console: document.querySelectorAll(".product-title").length should equal the number of items you expect.
  5. Paste the selector into the extension Selector mode, or use Pick on page.

Stable vs fragile selectors

FragileBetter
#root > div:nth-child(3) > div > span.product-title
.css-1x2y3z[data-testid="price"]
Copy selector from DevToolsA class that describes the content

Narrowing the scope

If .title also matches the sidebar, prefix the container: main .title or .results .title.

When a site has no good classes

Try attribute selectors such as [itemprop="name"], which many shops use for structured data.

FAQ

What does "Copy selector" in DevTools give me?
A path to that one element; it usually needs simplifying to match all items.
Why does my selector match zero items?
The content may load later, sit in an iframe, or the class changed. Scroll, wait and retry.
Is Pick on page free?
It is part of Selector mode, which has 3 free uses per day.

Related guides

Updated 2026-11-11.

Stop retyping
tables.

Add to Chrome, free ↗

Free, no account. Web exporter Pro is $9 once.