Decode escaped characters in URL
Using urllib
package (import urllib
) :
Python 2.7
From official documentation :
urllib.unquote(string)
Replace
%xx
escapes by their single-character equivalent.Example:
unquote('/%7Econnolly/')
yields'/~connolly/'
.
Python 3
From official documentation :
urllib.parse.unquote(string, encoding='utf-8', errors='replace')
[…]
Example:
unquote('/El%20Ni%C3%B1o/')
yields'/El Niño/'
.
And if you are using Python3
you could use:
import urllib.parse
urllib.parse.unquote(url)