Tranco
raw JSON → 0.8.1 verified Sat May 09 auth: no python
A Python library for accessing the Tranco top sites ranking, which is hardened against manipulation. Current version 0.8.1. Released periodically.
pip install tranco Common errors
error ModuleNotFoundError: No module named 'tranco' ↓
cause The package is not installed or the import path is incorrect.
fix
Install with
pip install tranco and use from tranco import Tranco. error AttributeError: module 'tranco' has no attribute 'Tranco' ↓
cause Trying to access the class via module incorrectly in older versions or after a bad install.
fix
Use
from tranco import Tranco and then instantiate with Tranco(). error ValueError: The Tranco list is not available for the specified date ↓
cause Requesting a list for a date that does not exist (e.g., future date or before dataset start).
fix
Use
t.list(date='latest') or check available dates with t.available_dates(). Warnings
breaking In v0.8.0, the API changed from `tranco.Tranco()` to `Tranco()` direct import. Old code using `import tranco; t = tranco.Tranco()` may still work but is deprecated. ↓
fix Use `from tranco import Tranco` and then `Tranco()`.
deprecated The `Tranco.list()` method returns a `TrancoList` object. Accessing `latest_list.top(10)` works, but iterating directly over the list object is deprecated; use `.top()` or `.list()` methods. ↓
fix Use `latest_list.top(n)` to get top n domains or `list(latest_list)` to get all.
gotcha The `cache` parameter defaults to `True` in v0.8.0+, which caches the list locally. If you have an old cache file, it may prevent fetching a fresh list unless you clear the cache or set `cache=False`. ↓
fix Set `cache=False` or delete the cache directory (`./.tranco` by default).
Imports
- Tranco
from tranco import Tranco
Quickstart
from tranco import Tranco
t = Tranco(cache=True, cache_dir='.tranco')
latest_list = t.list()
print(latest_list.top(10)[:5])