I am trying to extract and clean the domains from a list of URLs. I read the post
How to extract domain name from url?
So far I can do this
$ URI="http://user:pw@example.com:80/"
$ echo $URI | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/'
example.com
But in my list of URLS there are also some cases like below
example1.comDNT:
example2.comContent-Length:
I want to have output as below
example1.com
example2.com
Can I use python to solve this
Any advice would be appreciated
Thanks alot