Skip to main content
This guide walks you through advanced CSS selector strategies to help you extract structured data from a wide variety of web layouts using the Zenrows API.

Basic API Call Structure

All examples use the following basic API call pattern with the Zenrows API:

Essential CSS Selector Techniques

Basic Selectors

Target elements by their tag names, classes, or IDs:

Attribute Selectors

Extract content based on HTML attributes:

Positional Selectors

Target elements based on their position in the document:

Combining Multiple Selectors

Combine selectors for more specific targeting:

Practical Extraction Scenarios

E-commerce Product Extraction

Extract product details from a listing page:

Product Specification Tables

Extracting structured data from specification tables:

Real Estate Listings

Extracting property information:

News Articles and Blog Posts

Extracting content from articles:

Advanced Selection Techniques

Working with Pagination Elements

Identify and extract pagination information:
Extract multi-level navigation structures:

Social Media Content

Extract content from social media-style layouts:

Data Table Extraction

Extract structured data from tables:

Special Extraction Scenarios

Form Fields

Extract form field values and attributes:

Metadata Extraction

Extract metadata from the HTML <head>:

Troubleshooting Selectors

When your selectors aren’t working as expected, try these approaches:
  1. Make Selectors More Specific
  2. Check for iframes Content might be inside iframes that require additional handling.
  3. Handle Special Characters
  4. Use Developer Tools to Verify Always test your selectors using the browser developer tools first.

Testing Workflow

We recommend this workflow for developing and testing selectors:
  1. Test the selector in the browser using DevTools
  2. Extract Full HTML First
  3. Test Selectors Locally with Cheerio
  4. Refine and Apply CSS Selectors with Zenrows
By following these techniques, you can effectively extract data from even the most complex web layouts using Zenrows and CSS selectors.