Step #1: Download and parse the list
The public suffix list includes two main parts. ICANN and Private domains. The ICANN part starts with // ===BEGIN ICANN DOMAINS=== and ends with // ===END ICANN DOMAINS===. The same rule applies to the private domains, they’re section starts with // ===BEGIN PRIVATE DOMAINS=== and ends with // ===END PRIVATE DOMAINS===. We need to Consider this when we parse the list and create or tree of TLDs.
I’ve decided to add a mode to the parsed file and cache it somewhere in the filesystem. mode=1 means the TLD belongs to the ICANN section and mode=2 means private domains. The final parsed file looks something like this
















