Scenario
You need to extract product information from an e-commerce site:- Product titles, prices, and ratings
- Availability status
- Customer reviews
- Dynamic content loaded via JavaScript
Workflow
Start session and wait for page load
Navigate to the target page and ensure all dynamic content has loaded.Expected output:
Extract data using JavaScript evaluation
Use Expected output:
bdg dom eval to execute JavaScript and extract structured data.Use accessibility tree for semantic data
The accessibility tree provides semantic structure without HTML noise.Expected output:This is more token-efficient than parsing full HTML.
Handle pagination to extract all pages
Navigate through paginated results to collect complete dataset.
Extract data from specific product page
Navigate to a product detail page and extract comprehensive data.
Extract tabular data
For data in HTML tables, extract as structured JSON.Expected output (products-table.json):
Extraction Patterns
Extract all links
Extract images with alt text
Extract form field values
Extract meta tags
Extract JSON-LD structured data
Common Challenges
Content loaded via infinite scroll
Content loaded via infinite scroll
Solution: Scroll incrementally and check for new content.
Dynamic class names (React/CSS modules)
Dynamic class names (React/CSS modules)
Solution: Use stable attributes like
data-testid or semantic roles.Content in iframes
Content in iframes
Solution: Use CDP to switch to iframe context.
JavaScript-rendered content with delay
JavaScript-rendered content with delay
Solution: Poll for element existence before extraction.
Full Extraction Script Example
Automated product data extraction:Best Practices
Use semantic queries for reliability
Accessibility attributes are more stable than CSS classes:Extract incrementally
Don’t load everything into memory at once:Validate extracted data
Check for missing or malformed data:Next Steps
JavaScript Evaluation
Learn
bdg dom eval command in detailAccessibility Tree
Use semantic queries for data extraction
DOM Commands
Master DOM querying and inspection
CDP Access
Access raw CDP methods for advanced use cases

