Back to articles
How to Scrape Product Reviews from Any E-Commerce Site

How to Scrape Product Reviews from Any E-Commerce Site

via Dev.to TutorialАлексей Спинов

Product reviews are gold for market research. Here is how to extract them. Review Data Structure Most review systems return: Rating (1-5 stars) Review text Author name Date posted Verified purchase flag Helpful votes Method 1: JSON-LD (Easiest) Many e-commerce sites embed reviews as structured data: const cheerio = require ( " cheerio " ); async function getReviewsFromJsonLD ( url ) { const res = await fetch ( url ); const $ = cheerio . load ( await res . text ()); const scripts = $ ( " script[type=application/ld+json] " ); for ( const script of scripts ) { const data = JSON . parse ( $ ( script ). html ()); if ( data . review || data [ " @type " ] === " Product " ) { return { name : data . name , rating : data . aggregateRating ?. ratingValue , reviewCount : data . aggregateRating ?. reviewCount , reviews : ( data . review || []). map ( r => ({ rating : r . reviewRating ?. ratingValue , text : r . reviewBody , author : r . author ?. name , date : r . datePublished })) }; } } } Method

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
7 views

Related Articles