Skip to content Skip to sidebar Skip to footer

Python Post Request Encoding

here's the situation, i'm sending POST requests and trying to fetch the response with Python problem is that it distorts non latin letters, which doesn't happen when i fetch the sa

Solution 1:

Why don't your try thepage = the_page.decode('utf-8')instead of encode since what you want is to move from utf-8 encoded text to unicode - coding agnostic - internal strings?

Solution 2:

Two things. Firstly, you don't want to encode the response, you want to decode it:

thepage = the_page.decode('utf-8')

And secondly, you don't want to set the header on the response, you set it on the request, using the add_header method:

req.add_header('Content-Type', 'text/html;charset=utf-8')

Post a Comment for "Python Post Request Encoding"