Correct URL encoding
Chris Rebert
clp2 at rebertia.com
Sun Mar 15 19:27:43 EDT 2009
On Sun, Mar 15, 2009 at 4:21 PM, mattia <gervaz at gmail.com> wrote:
> I'm using urlopen in order to download some web pages. I've always to
> replace some characters that are in the url, so I've come up with:
> url.replace("|", "%7C").replace("/", "%2F").replace(" ", "+").replace
> (":", "%3A")
> There isn't a better way of doing this?
I believe you're looking for the aptly-named urlencode() function:
http://docs.python.org/library/urllib.html#urllib.urlencode
Cheers,
Chris
--
I have a blog:
http://blog.rebertia.com
More information about the Python-list
mailing list