frazman
frazman

Reputation: 33253

Text processing of an HTTP link in Python

Imagine that I have url

http://www.google.com/subdomain/blah-blah.../.. /..

So I want to extract 4 things from this 1) The Protocol: "http" 2) "www" 3) domain name : google" 4) "com" portion 5) subdomain par: all those after .com part But as you can see this link can be anything

ftp://google.net/hola-hola

now this might also be a valid link. So how do I extract these various portions of url using python

Upvotes: 1

Views: 118

Answers (1)

joel3000
joel3000

Reputation: 1319

See urlparse.

http://docs.python.org/library/urlparse.html

Upvotes: 8

Related Questions