Top level domain from URL in C#

后端 未结 7 1300
误落风尘
误落风尘 2020-11-29 10:11

I am using C# and ASP.NET for this.

We receive a lot of \"strange\" requests on our IIS 6.0 servers and I want to log and catalog these by domain.

Eg. we get

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 10:52

    I've written a library for use in .NET 2+ to help pick out the domain components of a URL.

    More details are on github but one benefit over previous options is that it can download the latest data from http://publicsuffix.org automatically (once per month) so the output from the library should be more-or-less on a par with the output used by web browsers to establish domain security boundaries (i.e. pretty good).

    It's not perfect yet but suits my needs and shouldn't take much work to adapt to other use cases so please fork and send a pull request if you want.

提交回复
热议问题