Advertisement
rfmonk

urlparse_urlparseattrs.py

Feb 8th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # this is from The Python
  4. # Standard Library by example
  5. # ISBN13: 9780321767349
  6.  
  7. from urlparse import urlparse
  8.  
  9. url = 'http://user:pwd@NetLoc:80/path;param?query=arg#frag'
  10. parsed = urlparse(url)
  11. print 'scheme   :', parsed.scheme
  12. print 'netloc   :', parsed.netloc
  13. print 'path     :', parsed.path
  14. print 'params   :', parsed.params
  15. print 'query    :', parsed.query
  16. print 'fragment :', parsed.fragment
  17. print 'username :', parsed.username
  18. print 'password :', parsed.password
  19. print 'hostname :', parsed.hostname, '(netloc in lowercase)'
  20. print 'port     :', parsed.port
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement