<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>67</id><slug>extracting-json-ld-from-product-pages-part-4-67</slug><title>Extracting JSON-LD from product pages, part 4</title><excerpt>For part 4, 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>4</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>For part 4, 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>Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.</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>Character encodings still cause trouble. Decode responses using the charset the server declares, and normalise text before comparing or storing it.</item></paragraphs></item><item><heading>A practical approach</heading><paragraphs><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>Log every request with its URL, status code and duration. When something goes wrong at two in the morning, those logs are the difference between a quick fix and a long investigation.</item><item>Be careful with relative URLs. Resolve every link against the page it came from, not against the site root, or you will request pages that do not exist.</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>5</authorId><authorName>Chen Patel</authorName><authorSlug>chen-patel</authorSlug><category>Data Engineering</category><tags><item>javascript</item><item>selenium</item></tags><publishedAt>2024-05-15T00:00:00.000Z</publishedAt><wordCount>229</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
