urllib2: non-ascii characters in url

Achim Domma domma at procoders.net
Wed Jun 18 10:10:35 EDT 2003


"Alan Kennedy" <alanmk at hotmail.com> wrote in message
news:3EF059D3.10ED7902 at hotmail.com...
> Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import urlparse
> >>> import urllib
> >>> def correcturl(u):
> ...     s, a, p, q, f = urlparse.urlsplit(u)
> ...     p = urllib.quote(p)
> ...     return urlparse.urlunsplit((s, a, p, q, f))

I had to add a

q = urllib.quote(q,"=&")

but then it works fine. Thanks!

Achim






More information about the Python-list mailing list