PyParseURI – JavaScript’s ParseURI Python Port

I use JavaScript heavily at work in hope to create a nice interface/experience. One little utility that I have used for different projects is Steven Levithan’s ParseURI. It’s easy and it gets the tedious URL parsing job done. Try the JavaScript demo out.

One lazy Sunday afternoon I decided to port it over to Python. The functionality and datatype the class returns remains true to the original but now you can use it in your Python based projects.

You can find PyParseURI over at GitHub

Or you can you easy_install:

easy_install pyparseuri

Here is an example of how to use it:

Usage:from parse_uri import ParseUri
p = ParseUri()
parsed_uri = p.parse('http://www.example.com')
print parsed_uri.authority
'www.example.com'
print parsed_uri.protocol
'http'

And so on....

Sample Output:
{
  'protocol': 'http',
  'authority': 'www.example.com',
  'anchor': None,
  'relative': '',
  'source': 'http://www.example.com',
  'host': 'www.example.com',
  'userInfo': None,
  'file': '',
  'queryKey': {},
  'directory': None,
  'query': None,
  'path': '',
  'password': None,
  'port': None,
  'user': None
}

Speak Your Mind

*


*

Fork me on GitHub