#tld #extract #domain

tldextract

extract domain info from a url

5 releases (3 breaking)

Uses old Rust 2015

0.5.1 Sep 11, 2018
0.5.0 Oct 30, 2017
0.4.0 Feb 9, 2017
0.3.0 Jan 9, 2017
0.1.0 Nov 12, 2016

#7 in #tld

Download history 4/week @ 2020-12-31 29/week @ 2021-01-07 26/week @ 2021-01-14 41/week @ 2021-01-21 17/week @ 2021-01-28 14/week @ 2021-02-04 30/week @ 2021-02-11 37/week @ 2021-02-18 26/week @ 2021-02-25 38/week @ 2021-03-04 80/week @ 2021-03-11 45/week @ 2021-03-18 97/week @ 2021-03-25 66/week @ 2021-04-01 75/week @ 2021-04-08 24/week @ 2021-04-15

97 downloads per month

MIT license

140KB
7.5K SLoC

tldExtract Travis Crates.io

A rust implementation of tldExtract. tldExtract accurately extracts TLD, including gTLD(generic top-level domain) and ccTLD ( country code top-level domain) from the domain and subdomains of a URL. For example, it extracts 'google' from 'http://www.google.com'.

Splitting the url with '.' and taking the last 2 elements does not work except for simple examples like .com domains. This does not work for complicated domains like http://forums.bbc.co.uk . The naive splitting method above will give you 'co' as the domain and 'uk' as the TLD, instead of 'bbc' and 'co.uk' respectively.

While tldExtract knows what all gTLDs and ccTLDs look like by looking up the currently living ones according to the Public Suffix List. So, tleExtract knows the subdomain and its domain from its country code.

Thanks to john-kurkowski, this project is mainly inspired by his work in python

documentation

Dependencies

~9.5MB
~211K SLoC