S
S
Sasha Filinsky2021-07-31 18:41:21
Python
Sasha Filinsky, 2021-07-31 18:41:21

How to fix the encoding when sending?

I send text via requests.get to carts, but this comes in TG

%20----------%20%D0%9F%D0%B5%D1%80%D0%B5%D1%81%D1%8B%D0%BB%D0%B0%D0%B5 %D0%BC%D0%BE%D0%B5%20%D1%81%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D0%B5 %20---------%D0%9E%D1%82:%20%20%3C
but everything is fine in the console. I figured out

that there is a # symbol. When I delete it, something like this happens. If I do not delete # then it comes to this character. How to fix this or how to translate urlencoded into UTF-8 exactly in TG?

Can it be fixed somewhere?
url = f'chat_id={list_data[1]}&text={msg}'
requests.get(f"https://api.telegram.org/bot{bot_token}/sendMessage", url)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-31
@UkaUkaa

If the sent text # is present or what?

requests.get(f"https://api.telegram.org/bot{bot_token}/sendMessage", {"chat_id": list_data[1], "text": msg})

In general, it is better to send POST requests so that there are no same limits on the length of the URL
requests.post(f"https://api.telegram.org/bot{bot_token}/sendMessage", data={"chat_id": list_data[1], "text": msg})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question