
Experienced scrapers know a secret: many sites already publish structured data for Google Rich Results. JSON-LD blocks in `<script type="application/ld+json">` tags contain clean Product, Article, LocalBusiness, and Organization schemas.
Extracting JSON-LD is faster and more stable than XPath. Product pages typically include name, price, currency, availability, brand, and SKU in one parse. Layout redesigns break CSS selectors; schema often survives.
Implementation in Scrapy: add a pipeline step that searches for ld+json scripts, parses with Python's json module, and maps schema.org types to your item model. Fallback to HTML selectors when JSON-LD is absent or incomplete.
Watch for: multiple JSON-LD blocks per page (BreadcrumbList + Product), @graph arrays, and invalid JSON from template errors. Validate with jsonschema against expected types.
At Scrapy Ninja, JSON-LD extraction is our first strategy for e-commerce and news clients. It reduces maintenance cost when sites refresh their UI — a common pain point for long-running scrapers.


