use Data::Tranco;
# get a random domain from the list
$domain = Data::Tranco->random_domain;
# get a random domain from the list with a specific suffix
$domain = Data::Tranco->random_domain("org");
# get the highest ranking domain
$domain = Data::Tranco->top_domain;
# get the highest ranking domain from the list with a specific suffix
$domain = Data::Tranco->top_domain("co.uk");
Data::Tranco provides an interface to the Tranco list of popular domain names.
$domain = Data::Tranco->random_domain($suffix);
Returns a randomly-selected domain from the list. If $suffix
is specified,
then only a domain that ends with that suffix will be returned.
$domain = Data::Tranco->top_domain($suffix);
Returns the highest-ranking domain from the list. If $suffix
is specified,
then the highest-ranking domain that ends with that suffix will be returned.
The Tranco list is published as a zip-compressed CSV file. By default, Data::Tranco will automatically download that file, extract the CSV file, and write it to an SQLite database if (a) the file doesn't exist yet or (b) it's more than a day old.
If you want to control this behaviour, you can use the following:
This is how old the local file can be (in seconds) before it is updated. It is 86400 seconds by default.
If you set this value to 1
then Data::Tranco will not update the database.
This will force an update to the database.