Skip to main content

How to extract star rating information

Updated over 2 weeks ago

You are browsing a tutorial guide for the latest Octoparse version. If you are running an older version of Octoparse, we strongly recommend you upgrade because it is faster, easier, and more robust! Download and upgrade here if you haven't already done so!

Some websites (like Trustpilot) store ratings in HTML attributes rather than plain text. Here’s how to extract them:

Example Page:

📌 Trustpilot Review - Airforce Gift Shophttps://www.trustpilot.com/review/airforcegiftshop.co.uk

There are two ways to fetch the star rating info.


Method 1: Extract Attributes from HTML

Best for

Simple rating extraction from alt, src, or other attributes.

Steps:

  1. Select the star rating element on the page.

  2. In the Tips panel, choose:

    • Image URL (if rating is an image)

    • OuterHtml (for raw HTML extraction)

  3. Click Extract Data"..." (More Options)Customize Field.

  4. Select "Other Attributes" → Pick alt or src.

  5. Preview & confirm the extracted value (e.g., alt="5 stars").


Method 2: Extract & Clean HTML with RegEx

Best for

Complex cases where ratings are buried in HTML.

Steps:

  1. Select the rating then choose OuterHtml.

  2. Click Extract Data"..."Clean Data.

  3. Add StepMatch with Regular Expression (RegEx).

For Octoparse Version 8.8.0 and later

  1. Click Need help with RegEx? Try our RegEx tools!

  2. For each test string, manually highlight only the text you want to match.

  3. Click Generate. The AI will analyze your examples and propose a RegEx pattern.

  4. Click Test to verify the pattern works against all your samples.

  5. Click Apply & Save, give your pattern a name, and confirm.

Before version 8.8.0

  1. Two options:

    • Manually enter RegEx (if familiar).

    • Use RegEx Tool (recommended for beginners).

  2. In the RegEx Tool:

    • Click Start With → Enter text before the rating (e.g., alt=").

    • Click End With → Enter text after the rating (e.g., ").

    • Click Match to verify.

  3. Apply → Confirm settings.

Did this answer your question?