<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>147</id><slug>extracting-json-ld-from-product-pages-part-8-147</slug><title>Extracting JSON-LD from product pages, part 8</title><excerpt>For part 8, we revisit the basics with a fresh example and a few lessons learned the hard way. Many product pages already contain a clean, structured description of themselves in a script tag meant…</excerpt><seriesName>Extracting JSON-LD from product pages</seriesName><seriesPart>8</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>For part 8, we revisit the basics with a fresh example and a few lessons learned the hard way. Many product pages already contain a clean, structured description of themselves in a script tag meant for search engines. Reading it is often more reliable than parsing the visible HTML.</item></paragraphs></item><item><heading>Common pitfalls</heading><paragraphs><item>Pagination comes in several shapes: numbered pages, next links, offsets and opaque cursors. Each has trade-offs, and a robust scraper should detect the end of the result set rather than assuming a fixed number of pages.</item><item>Always identify your client honestly with a descriptive User-Agent, and keep your request rate modest. A crawler that behaves like a considerate visitor is far less likely to cause problems for the site operator.</item><item>Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.</item></paragraphs></item><item><heading>Going further</heading><paragraphs><item>Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream.</item><item>Write small, focused tests for your parsers using saved HTML fixtures. They run in milliseconds and catch layout changes long before a full crawl would.</item><item>Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.</item></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Select script[type='application/ld+json'], parse every block, and pick the one whose @type matches what you need. Fall back to HTML only for missing fields.</item></paragraphs></item></sections><authorId>4</authorId><authorName>Lucas Silva</authorName><authorSlug>lucas-silva</authorSlug><category>Data Engineering</category><tags><item>selenium</item><item>json</item><item>testing</item><item>python</item></tags><publishedAt>2024-08-19T00:00:00.000Z</publishedAt><wordCount>227</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
