When I enter a URL into maps.google.com such as https://dl.dropbox.com/u/94943007/file.kml , it will encode this URL into:
https:%2F%2Fdl.dropbox.com%2Fu%2F94943007%2Ffile.kml
I am wondering what is this encoding called and is there a way to encode a URL like this using python?
I tried this:
The process is called URL encoding:
>>> urllib.quote('https://dl.dropbox.com/u/94943007/file.kml', '')
'https%3A%2F%2Fdl.dropbox.com%2Fu%2F94943007%2Ffile.kml'
but did not get the expected results:
'https%3A//dl.dropbox.com/u/94943007/file.kml'
what i need is this:
https:%2F%2Fdl.dropbox.com%2Fu%2F94943007%2Ffile.kml
how do i encode this URL properly?
the documentation here:
https://developers.google.com/maps/documentation/webservices/
states:
All characters to be URL-encoded are encoded using a '%' character and a two-character hex value corresponding to their UTF-8 character. For example, 上海+中國 in UTF-8 would be URL-encoded as %E4%B8%8A%E6%B5%B7%2B%E4%B8%AD%E5%9C%8B. The string ? and the Mysterians would be URL-encoded as %3F+and+the+Mysterians.