1

I need to send a request from the backend I'm doing in Python to an API via URL.

The method requests.get(URL) automatically makes the respective encoding to UTF-8.

The problem is that the API page, when they are special characters, such as in Russian, German, Spanish, etc.... in the address goes the parameter (query, for example) and it is already sent encoded.

For example, the Russian word "Бавария Мюнхен" in UTF-8 becomes:

"%D0%91%D0%B0%D0%B2%D0%B0%D1%80%D0%B8%D1%8F%20%D0%9C%D1%8E%D0%BD%D1%85%D0%B5%D0%BD"

but it turns out that the url when entering manually from the website, to each % adds a 25, that is, it remains as %25 plus the letter that follows in the query encoded.

enter image description here enter image description here

The website is RSS Dog.

Questions:

  • How do I manually add that "%25"?
  • Is a coding method that does that in Python.

Translated with www.DeepL.com/Translator :v

jwpfox
  • 5,124
  • 11
  • 45
  • 42
  • Take a look at this question: https://stackoverflow.com/questions/16566069/url-decode-utf-8-in-python Does that help you? If so, why not? – Cale Sweeney Jan 05 '18 at 01:30
  • 1
    Yes bro, thank you, but the problem is that "requests. get" automatically converts it and the url that is sent stays with the % only, and what I need is that it is not % but %25. – Andres Martinez Jan 05 '18 at 02:06

1 Answers1

0

The method in python that does it is urllib.quote and urllib.unquote.

%25 is equal to % when unquoted, so you could unquote the entire string, insert them, and then reinsert them if you wanted, but it seems like you're accidentally double quoting the querystring.

Dash Winterson
  • 1,197
  • 8
  • 19