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=autoturns a page into structured JSON with no selectors. - How
extract_fieldstrims the JSON to the fields you need. - How
css_extractorreturns exactly the elements you point at, as JSON. - How the official Python SDK wraps the request you wrote by hand in Lesson 1.
Install the Python SDK
Thefetch() 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 aparsed object, next to the raw html. On the catalog page, parsed holds a products list. Create catalog.py:
Python (SDK)
python catalog.py:
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)
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)
python product_page.py:
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 hascatalog.py and product_page.py. You can:
- Get a whole catalog page as JSON with
extract=auto, and trim it withextract_fields. - Read exact fields from a known layout with
css_extractor, as strings or lists. - Use
ZenRowsClientfrom the official SDK in place of a hand-written request.
Next lesson
Lesson 3: Discover every product with Crawl
Start from the catalog and let Crawl follow the links to every product page.