You'll need URL quoting here, not HTML quoting. That's ``urllib.quote``.