I need to build a function which parses the domain from a URL.
So, with
http://google.com/dhasjkdas/sadsdds/sdda/sdads.html
or
http://www.google.com/dhasjkdas/sadsdds/sdda/sdads.html
it should return google.com
with
http://google.co.uk/dhasjkdas/sadsdds/sdda/sdads.html
it should return google.co.uk.
Check out
parse_url():parse_urldoesn’t handle really badly mangled urls very well, but is fine if you generally expect decent urls.