[Twisted-Python] URL encoding
Is there any method in twisted that does proper url encoding? For example 'http://www.example.com/part1 part2.html' -> 'http://www.example.com/part1%20part2.html'
On Mon, 24 Mar 2008 14:48:22 +0100, Vasil Vangelovski <vvangelovski@gmail.com> wrote:
Is there any method in twisted that does proper url encoding? For example 'http://www.example.com/part1 part2.html' -> 'http://www.example.com/part1%20part2.html'
See the stdlib urllib module for APIs for manipulating URLs. Jean-Paul
On Mon, Mar 24, 2008 at 7:48 AM, Vasil Vangelovski <vvangelovski@gmail.com> wrote:
Is there any method in twisted that does proper url encoding? For example 'http://www.example.com/part1 part2.html' -> 'http://www.example.com/part1%20part2.html'
What about urllib.quote or urllib.urlencode? http://docs.python.org/lib/module-urllib.html ~ Nathan
urllib.quote is useless as is
urllib.quote('http://www.example.com/part1 part2.html') 'http%3A//www.example.com/part1%20part2.html
and from what I understand urllib.urlencode is for encoding query parameters. On Mon, Mar 24, 2008 at 3:40 PM, Nathan <nathan.stocks@gmail.com> wrote:
On Mon, Mar 24, 2008 at 7:48 AM, Vasil Vangelovski <vvangelovski@gmail.com> wrote:
Is there any method in twisted that does proper url encoding? For example 'http://www.example.com/part1 part2.html' -> 'http://www.example.com/part1%20part2.html'
What about urllib.quote or urllib.urlencode?
http://docs.python.org/lib/module-urllib.html
~ Nathan
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On Mon, 24 Mar 2008 16:20:05 +0100, Vasil Vangelovski <vvangelovski@gmail.com> wrote:
urllib.quote is useless as is
urllib.quote('http://www.example.com/part1 part2.html') 'http%3A//www.example.com/part1%20part2.html
and from what I understand urllib.urlencode is for encoding query parameters.
It's not useless, it just doesn't make any sense to use it that way. Use urllib.quote on each segment value _before_ you build the larger URL out of it. 'http://www.example.com/' + urllib.quote('part1 part2.html') Since this isn't really Twisted related, please follow up on the subject on comp.lang.python. Jean-Paul
On Mon, Mar 24, 2008 at 11:20 AM, Vasil Vangelovski <vvangelovski@gmail.com> wrote:
urllib.quote is useless as is
urllib.quote('http://www.example.com/part1 part2.html') 'http%3A//www.example.com/part1%20part2.html
and from what I understand urllib.urlencode is for encoding query parameters.
You want to quote only everything after "http://". ':' is valid only to delimit the schema from the URI - so the quoting is correct. -Drew
On Mon, Mar 24, 2008 at 9:20 AM, Vasil Vangelovski <vvangelovski@gmail.com> wrote:
urllib.quote is useless as is
urllib.quote('http://www.example.com/part1 part2.html') 'http%3A//www.example.com/part1%20part2.html
So don't give it the 'http://www.example.com/' part. ~ Nathan
participants (5)
-
Drew Smathers
-
J. Cliff Dyer
-
Jean-Paul Calderone
-
Nathan
-
Vasil Vangelovski