I wrote the following code to extract Get parameters from url like this:
from urllib.parse import urlparse
from urllib.parse import parse_qs
url = 'https://www.example.com/some_path?some_key=some_value&tt=new_value'
parsed_url = urlparse(url)
for val in parse_qs(parsed_url.query):
print(val)
it works great with the above url but once I do url-encoding (which is still a valid url scheme as browsers accept it) like this:
https://www.example.com/some_path?some_key%3Dsome_value%26tt%3Dnew_value
My code doesn't output anything, why is that and how to fix?
Note: I know some of you may suggest doing url-decoding for the input but I don't think this will solve all cases, what if there was another encoding like for urls which is valid and should be parsed correctly?