P
P
pcdesign2015-12-24 17:31:35
Python
pcdesign, 2015-12-24 17:31:35

How to decode cp-1251 to utf-8 on requests?

Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45)
Here is the code:

#!/usr/bin/python
# -*- coding: utf8 -*-
import requests
import sys

with requests.Session() as s:
        r = s.get('http://account.telphin.ru')
        print r.text

When outputting to print, I get questions.
<a class="asdf" href="http://www.telphin.ru/abonentam/support/#security"><h2>????????! ???????? ????????? ???????????? ????? ???????!</h2></a>


                                        <h1></h1>


<table class="abon_content"><tr>
        <h2>???? ?? ???????????? ???????? ????????</h2>

All my tricks with encode('utf8') failed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2015-12-24
@pcdesign

stackoverflow.com/questions/7555335/how-to-convert...
decode('cp1251').encode('utf8')

P
Peter, 2015-12-24
@petermzg

And where do you output this print?
Maybe this console does not know the font to display characters received from cp-1251

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question