Skip to main content
In Lesson 1 you fetched the catalog as HTML and markdown. Now you stop parsing pages yourself and let Zenrows return the data as JSON. What you’ll build: two scripts. catalog.py lists every product on a catalog page as JSON with Extract. product_page.py reads the exact fields you choose from one product page with CSS selectors, the same fields the tracker collects for every product in Lesson 4. What you’ll learn:
  • How extract=auto turns a page into structured JSON with no selectors.
  • How extract_fields trims the JSON to the fields you need.
  • How css_extractor returns exactly the elements you point at, as JSON.
  • How the official Python SDK wraps the request you wrote by hand in Lesson 1.
Time: about 10 minutes.

Install the Python SDK

The fetch() helper from Lesson 1 is a thin wrapper over https://api.zenrows.com/v1/. The official SDK ships the same wrapper as ZenRowsClient, plus clients for Crawl and Batch that you’ll use in Lessons 3 and 4. Install it in your project folder:
client.fetch(url, params={...}) sends a Fetch request with your parameters. client.extract(url) sends the same request with extract=auto and mode=auto already set.

Get the catalog as JSON with Extract

Extract reads a page and returns its data in a parsed object, next to the raw html. On the catalog page, parsed holds a products list. Create catalog.py:
Python (SDK)
Run python catalog.py:
You wrote no selectors. Extract recognized a product listing and returned every product with a numeric price, a currency and a link.

Pick the fields you need

parsed carries every field Extract found. Add extract_fields with a comma-separated list, dot-notated inside a group, to keep the ones the tracker uses. Replace the request and the prints in catalog.py:
Python (SDK)
The output is now a compact price list:
Field names come from each site. Send one request without extract_fields first, read the names in parsed, then pin the ones you want. See Selecting the fields you need.

Read exact product fields with CSS selectors

For the tracker you also want details that live on each product page: the SKU, the category, and the sizes and colors a shopper can pick. When you know the page layout, css_extractor is the precise tool: you map a name to a CSS selector, and Zenrows returns those elements as JSON. Add @attribute after a selector to read an attribute instead of the text. Create product_page.py:
Python (SDK)
Run python product_page.py:
A selector that matches one element returns a string, and one that matches several returns a list. option:not(:first-child) skips the “Choose an option” placeholder in each dropdown. Keep PRODUCT_SELECTORS as it is: Lesson 4 sends it with every product URL.
Extract or CSS selectors? Reach for extract=auto when you want the data a page offers with no setup. Reach for css_extractor when you know the page and want exact elements under your own field names. Both return JSON from the same Fetch request.

Ask your AI agent

With the Zenrows MCP server connected to Claude, Cursor or any MCP client, paste this prompt. Your agent picks the right Zenrows tools and settings on its own.

What you built

Your project now has catalog.py and product_page.py. You can:
  • Get a whole catalog page as JSON with extract=auto, and trim it with extract_fields.
  • Read exact fields from a known layout with css_extractor, as strings or lists.
  • Use ZenRowsClient from the official SDK in place of a hand-written request.
You have the data for 16 products on one page. Next, you find the URL of every product in the store.

Next lesson

Lesson 3: Discover every product with Crawl

Start from the catalog and let Crawl follow the links to every product page.