Friday 2 June 2017

How to use request module to fetch urls with unicode characters?

For example the link to my profile here on stack overflow looks like this:

https://stackoverflow.com/users/607407/tomáš-zato

But if I copy it from browser bar, the actual value is:

https://stackoverflow.com/users/607407/tom%C3%A1%C5%A1-zato

You can paste either of these in your browser and it will work. But if I send non-encoded URL with unicode (to a different webpage) I get an error:

<html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.
</body></html>

How to convert unicode characters in URL to their %XX variants?



via Tomáš Zato

No comments:

Post a Comment