-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurlparse_urlsplit.py
More file actions
31 lines (27 loc) · 851 Bytes
/
Copy pathurlparse_urlsplit.py
File metadata and controls
31 lines (27 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
"""Parsing URLs
"""
#end_pymotw_header
from urlparse import urlsplit
url = 'http://user:pwd@NetLoc:80/p1;param/p2;param?query=arg#frag'
parsed = urlsplit(url)
print parsed
print 'scheme :', parsed.scheme
print 'netloc :', parsed.netloc
print 'path :', parsed.path
print 'query :', parsed.query
print 'fragment:', parsed.fragment
print 'username:', parsed.username
print 'password:', parsed.password
print 'hostname:', parsed.hostname, '(netloc in lowercase)'
print 'port :', parsed.port
# SplitResult(scheme='http', netloc='user:pwd@NetLoc:80', path='/p1;param/p2;param', query='query=arg', fragment='frag')
# scheme : http
# netloc : user:pwd@NetLoc:80
# path : /p1;param/p2;param
# query : query=arg
# fragment: frag
# username: user
# password: pwd
# hostname: netloc (netloc in lowercase)
# port : 80