trustpilot-scraper
Turn a company's public Trustpilot reviews into clean Python dicts, CSV or JSON, in one call.
The trustpilot_scraper library is a Python package for scraping Trustpilot reviews. Give it a
Trustpilot review page (or just the company's domain) and it returns every review as a dictionary.
Businesses can use it to collect Trustpilot reviews for market analysis, sentiment analysis and competitor benchmarking, and to learn from customer feedback to improve products, services and online reputation.
Heads-up (October 2026): Trustpilot currently puts an AWS WAF bot-verification page in front of its review pages, and plain HTTP clients such as
requestsoften get HTTP 403. When that happens this library raisesTrustpilotBlockedErrorrather than quietly returning an empty list. The library does not try to get around the check. If you are blocked, save the page from your browser and parse it withparse_reviews_html()(see below). The page's data format was checked against a live page on 2026-10-31.
Features
- Reads the page's embedded
__NEXT_DATA__JSON instead of brittle CSS selectors. - Handles pagination automatically, stopping at the real last page (or at
max_pages). - Retrieves date, author, body, heading, rating and location, and with
extended=Truealso the review id, experience date, verification flag, likes, language and the company's reply. - Removes duplicate reviews (by review id) and keeps page order.
- Waits politely between requests (2 s by default) and lets you pass your own
requests.Session. - Raises clear exceptions when something goes wrong:
TrustpilotBlockedError,TrustpilotParseErrorandTrustpilotError. - Includes a
trustpilot-scrapercommand that writes JSON, JSONL or CSV. - Fully typed (
py.typed) and light: onlyrequestsandbeautifulsoup4are required.
Installation
pip install trustpilot_scraper
# optional: pandas, for working with results as a DataFrame
pip install "trustpilot_scraper[pandas]"
Requires Python 3.10+.
Quick start
from trustpilot_scraper import scrape_trustpilot_reviews
reviews = scrape_trustpilot_reviews(
"https://www.trustpilot.com/review/www.example.com", # or just "www.example.com"
max_pages=2, # omit to fetch every page
delay=2.0, # seconds between requests
)
for review in reviews:
print(review)
Each review is a dict with the same keys as earlier versions:
{'Date': '2026-10-29', 'Author': 'Reviewer 1', 'Body': 'Synthetic review body number 1.',
'Heading': 'Synthetic heading 1', 'Rating': 5, 'Location': 'US'}
With extended=True each dict also has ReviewId, ExperienceDate, Verified, Likes,
Language, Reply and ReplyDate.
Parse HTML you already have
from pathlib import Path
from trustpilot_scraper import parse_reviews_html, normalize_review
html = Path("amazon_page1.html").read_text(encoding="utf-8") # saved from your browser
reviews = [normalize_review(r, extended=True) for r in parse_reviews_html(html)]
Handle blocking explicitly
from trustpilot_scraper import scrape_trustpilot_reviews, TrustpilotBlockedError
try:
reviews = scrape_trustpilot_reviews("www.example.com", max_pages=1)
except TrustpilotBlockedError as exc:
print("Trustpilot refused the request:", exc)
Command line
trustpilot-scraper www.example.com --max-pages 3 -o reviews.csv
trustpilot-scraper https://www.trustpilot.com/review/www.example.com --extended -o reviews.jsonl
trustpilot-scraper www.example.com # JSON to stdout, first page only
The exit code is 1 and the error goes to stderr when a request is blocked or fails.
Use cases
- Sentiment analysis: feed
BodyandRatinginto your NLP pipeline. - Competitor benchmarking: compare rating distributions across companies.
- Customer-support QA: use
extended=Trueto see which reviews got a company reply. - Dashboards:
pandas.DataFrame(reviews)gives a ready-to-plot table.
API overview
| Function | Purpose |
|---|---|
scrape_trustpilot_reviews(base_url, *, max_pages=None, delay=2.0, extended=False, session=None, timeout=30.0) |
Fetch all (or max_pages) pages and return a list of dicts. |
iter_trustpilot_reviews(...) |
The same, but as a lazy generator that fetches page by page. |
get_reviews_from_page(url, *, session=None, timeout=30.0) |
Fetch one page and return the raw Trustpilot review objects. |
parse_reviews_html(html) |
Pull the raw review objects out of an HTML string. |
parse_next_data(html) |
Return the whole decoded __NEXT_DATA__ JSON. |
normalize_review(raw, *, extended=False) |
Turn a raw review object into the flat dict shown above. |
normalize_url(company) |
"www.example.com" becomes "https://www.trustpilot.com/review/www.example.com". |
Exceptions: TrustpilotError (base class), TrustpilotBlockedError (HTTP 403/429 or a
verification page) and TrustpilotParseError (the page has no review data).
Upgrading from 0.x
from trustpilot_scraper.scraper import scrape_trustpilot_reviewsstill works, and the output keys are unchanged.- Version 0.10 on PyPI shipped a wheel without the Python package in it. 1.0.0 fixes the packaging.
- Errors now raise exceptions instead of returning
[]. pandasis no longer a required dependency.
Responsible use
Only scrape public pages, keep the request rate low (the default delay is 2 s), and follow Trustpilot's terms of use and the data-protection law that applies to you.
Contributing
Pull requests are welcome. See CONTRIBUTING.md.
pip install -e ".[dev]"
ruff check . && ruff format --check . && pytest
The tests run offline against saved HTML fixtures in tests/fixtures/.
License
MIT. See LICENSE.
Metadata
Release files for trustpilot-scraper 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trustpilot_scraper-1.0.0.tar.gz | 17.2 kB | Without provenance | Details for trustpilot_scraper-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trustpilot_scraper-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for trustpilot_scraper-1.0.0-py3-none-any.whl |
Total release size: 28.3 kB
Release files / trustpilot_scraper-1.0.0.tar.gz
| Download URL | trustpilot_scraper-1.0.0.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0515ab0dbb92226647227a4c2f31bea46ee5d552c78742424fe8c07c05bea2b
|
|
BLAKE2b-256 checksum How to use checksums |
2bb1a3e74025140d091308b0119b6dbab66a11dc15fb3c5b9393b909f5f4a8d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Release files / trustpilot_scraper-1.0.0-py3-none-any.whl
| Download URL | trustpilot_scraper-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3ef76b5ea9d2c85c181b4eb91419845793ff5e79c7aa9cac5bbfb203f648d70
|
|
BLAKE2b-256 checksum How to use checksums |
d3dffa9f2fa386d7cb1274647ca072fa8ea5e6adf3068048de2221c2595643f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Security for trustpilot-scraper 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.