pycountry icon indicating copy to clipboard operation
pycountry copied to clipboard

Add ccTLD information on Country data

Open matheusmatos opened this issue 6 months ago • 1 comments

Hello guys,

I would love to having TLD (Top Level Domain) information when getting a Country with pycountry. For example:

>>> import pycountry
>>> brazil = pycountry.countries.get(alpha_3="BRA")
>>> brazil.tld
".br"

I've created a script using Geonames data (txt file link), and found only three countries where TLD is different from ISO-3166 (.alpha_2 property):

  • BL is different of gp
  • GB is different of uk
  • MF is different of gp

Despite the small differences, they do exist 😢. If you agree with the idea, I can open a PR. We can do this in two ways:

  1. Adapting the generate.py to store the data directly into the iso3166-1.json file; or
  2. Alternatively, creating a separate tld_list.json file and integrating it within the library class.

Thank you, Matheus Matos

matheusmatos avatar Aug 03 '24 22:08 matheusmatos