Python how to split a domain with urlparse


SUBMITTED BY: alemotta

DATE: April 13, 2017, 9:16 p.m.

FORMAT: Text only

SIZE: 187 Bytes

HITS: 594

  1. #Python how to split a domain with urlparse
  2. import urlparse
  3. url = "http://python.org"
  4. domain = urlparse.urlsplit(url)[1].split(':')[0]
  5. print "The domain name of the url is: ", domain

comments powered by Disqus