My favorites | Sign in
Project Logo
                
Code license: New BSD License
Labels: python, url, parser
Show all Featured wiki pages:
HowToBuildGoogleUrlWithLinux
Links:
Blogs:
Feeds:
People details
Project owners:
  flier.lu

A small library for parsing and canonicalizing URLs.

You could use it to parse URL with CUrl like urlparse.urlunparse

>>> import gurl
>>> url = gurl.Url("http://user:pass@www.google.com:8080/index.htm?id=1234#tag")
>>> print url.scheme
http
>>> print url.username
user
>>> print url.password
pass
>>> print url.hostname
www.google.com
>>> print url.port
8080
>>> print url.path
/index.htm
>>> print url.query
id=1234
>>> print url.fragment
tag
>>> print url.filename
index.htm
>>> print url.host
http://user:pass@www.google.com:8080/
>>> print url.origin
http://www.google.com:8080/
>>> print url.hostisip
False
>>> print url.request
/index.htm?id=1234
>>> print url
http://user:pass@www.google.com:8080/index.htm?id=1234#tag  

or replace some components of a immutability URL with UrlBuilder

>>> url = gurl.UrlBuilder(url)
>>> url.scheme = "https"
>>> url.port = 8443
>>> url.username = None
>>> url.password = None
>>> print url
https://www.google.com:8443/index.htm?id=1234#tag

Please check the unit test for more detail.

The most power feature of google-url is the compatibility, please check its unit test for more detail.









Hosted by Google Code