{"data":{"id":7,"slug":"extracting-json-ld-from-product-pages-7","title":"Extracting JSON-LD from product pages","excerpt":"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.","seriesName":"Extracting JSON-LD from product pages","seriesPart":1,"sections":[{"heading":"Introduction","paragraphs":["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."]},{"heading":"Common pitfalls","paragraphs":["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.","Character encodings still cause trouble. Decode responses using the charset the server declares, and normalise text before comparing or storing it."]},{"heading":"Step by step","paragraphs":["Selectors are the most fragile part of any scraper. Prefer stable attributes such as data-testid or semantic structure over generated class names, which can change on every deploy.","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."]},{"heading":"Key takeaway","paragraphs":["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."]}],"authorId":5,"authorName":"Chen Patel","authorSlug":"chen-patel","category":"Data Engineering","tags":["ethics"],"publishedAt":"2025-05-17T00:00:00.000Z","wordCount":164,"readingTimeMinutes":2}}