Split a domain
- How to use the Hacker News API
- Writing Simple Views for Your First Python Django Application
- How to split string variables in Python
This is a simple script to split the domain name from a URL. It does that by usingPythons urlparse module.
import urlparse url = "http://python.org" domain = urlparse.urlsplit(url)[1].split(':')[0] print "The domain name of the url is: ", domain