0

I'm trying to get TLDs of urls. The Problem is, domains can be multileveled...

Examples

  • mydomain.com
  • www.mydomain.com
  • beta.www.mydomain.com
  • Result should be: com

and

  • mydomain.com.au
  • www.mydomain.com.au
  • beta.www.mydomain.com.au
  • Result should be: com.au

Any ideas how to do this without defining all the TLDs I want to work with?

Fantasterei
  • 465
  • 3
  • 11
  • 2
    It seems there is no fixed way. References: [Get domain name of a url in C# / .NET](http://stackoverflow.com/a/16474022/6741868) and [Top level domain from URL in C#](http://stackoverflow.com/a/4983045/6741868). – Keyur PATEL Sep 15 '16 at 09:30
  • @KeyurPATEL Indeed, there's no way to distinguish second level domain from regular domain without a fixed list of top and second level domains. – Martheen Sep 15 '16 at 09:32
  • @Martheen and the list varies depending on what a country's registrar, take a look here: [How to extract top-level domain name (TLD) from URL](http://stackoverflow.com/a/1066947/6741868). Although its on python, the concept is same. – Keyur PATEL Sep 15 '16 at 09:35
  • @KeyurPATEL I'm not OP, I don't really care about this problem, just pointing out in case OP insist there's a magical code-only way to solve their problem. – Martheen Sep 15 '16 at 09:36
  • Oh haha. Anyways the question's been marked duplicate already :p – Keyur PATEL Sep 15 '16 at 09:37

0 Answers0