Can I scrape user ratings along with reviews from Trustpilot?

Trustpilot's terms of service generally prohibit the scraping of their website. Trustpilot provides an API for accessing reviews and rating data, and they encourage users to utilize this API for legitimate purposes.

Web scraping can be a legal gray area and can violate the terms of service of many websites. It is imperative to respect the terms of service and copyright laws when considering scraping data from any website. Unauthorized scraping can lead to legal consequences, being banned from the service, or other penalties.

If you have a legitimate need to access user ratings and reviews from Trustpilot, the proper way to do so would be through their API, which would likely require you to register for an API key and adhere to their usage guidelines and limitations.

Here's an example of how you might use the Trustpilot API to retrieve reviews, using Python with the requests library. Note that you would need to replace YOUR_API_KEY, YOUR_ACCESS_TOKEN, and other placeholders with actual values obtained from Trustpilot when you register for API access.

import requests

# Replace with your actual Trustpilot API key and access token
api_key = 'YOUR_API_KEY'
access_token = 'YOUR_ACCESS_TOKEN'
business_unit_id = 'BUSINESS_UNIT_ID'  # Replace with the actual business unit ID

headers = {
    'Authorization': f'Bearer {access_token}',
}

params = {
    'apikey': api_key,
}

url = f'https://api.trustpilot.com/v1/business-units/{business_unit_id}/reviews'

response = requests.get(url, headers=headers, params=params)

if response.status_code == 200:
    reviews = response.json()
    for review in reviews['reviews']:
        print(f"Rating: {review['stars']}")
        print(f"Review: {review['text']}\n")
else:
    print(f"Failed to retrieve reviews: {response.status_code}")

Before using the Trustpilot API, you would need to go through their authentication process to obtain an access token. Trustpilot's API documentation provides detailed information on how to authenticate and use their API.

Keep in mind that scraping or using an API without proper authorization or in violation of the terms of service can be illegal and unethical. Always review the terms of service of the website and ensure that you have the right to access and use the data you are interested in. If in doubt, it's best to contact Trustpilot directly to ask for permission or guidance on how to legally obtain the data you need.

Related Questions

Get Started Now

WebScraping.AI provides rotating proxies, Chromium rendering and built-in HTML parser for web scraping
Icon