Back to articles
How to Scrape Trustpilot Reviews for Competitor Analysis

How to Scrape Trustpilot Reviews for Competitor Analysis

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

Trustpilot has reviews for 1M+ businesses. Here's how to extract them for competitive analysis. Trustpilot's Public API Trustpilot pages load review data via internal APIs: async function getTrustpilotReviews ( domain , page = 1 ) { const url = `https://www.trustpilot.com/review/ ${ domain } ?page= ${ page } ` ; const res = await fetch ( url , { headers : { ' User-Agent ' : ' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' } }); const html = await res . text (); // Trustpilot embeds review data as JSON-LD const jsonLdMatch = html . match ( /<script type="application \/ ld \+ json"> ( .* ?) < \/ script>/g s ); if ( jsonLdMatch ) { for ( const match of jsonLdMatch ) { const json = JSON . parse ( match . replace ( /< [^ > ] +>/g , '' )); if ( json [ ' @type ' ] === ' LocalBusiness ' || json . review ) { return json ; } } } } What Data You Get Overall rating (1-5 stars) Total review count Individual reviews: text, rating, date, author Business response to reviews Category ra

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
2 views

Related Articles