Answer the question
In order to leave comments, you need to log in
How to set request encoding in requests?
Good afternoon!
I'm trying to fill out a form and submit a request like this:
# -*- coding: windows-1251 -*-
import requests
payload = {"StFIO": "Иван"}
r = requests.post("http://192.192.192.192/", data=payload)
r.encoding = "windows-1251"
body_data = r.text
print(body_data)
<td width="653" class="style1"><input name="StFIO" type="text" id="StFIO" size="78" maxlength="78" value="�ван"></td>
Answer the question
In order to leave comments, you need to log in
Why are you using "windows-125" encoding to submit the form to the site? Almost always, "utf-8" encoding is used for web applications. Try declaring the "coding" argument with the value "utf-8", and also set the r.encoding variable to the value "utf-8" or remove this line in your script altogether.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question