R
R
raw12018-05-07 13:15:11
Python
raw1, 2018-05-07 13:15:11

How to get content of html page with russian text?

r = requests.get(url).text
print(r)

Gives an error message
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 165-169: character maps to <undefined>

If doing so
r = requests.get(url).text
print(r.encode("utf-8"))

I get something incomprehensible instead of the Russian language
<li><a href="/info/partners">\xd0\x9f\xd0\xb0\xd1\x80\xd1\x82\xd0\xbd\xd0\xb5\xd1\x80\xd0\xb0\xd0\xbc</a></li>\n                    <li><a href="/info/agreement">\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c\xd1\x81\xd0\xba\xd0\xbe\xd0\xb5 \xd1\x81\xd0\xbe\xd0\xb3\xd0\xbb\xd0\xb0\xd1\x88\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5</a></li>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2018-05-07
@sanya84

<li><a href="/info/partners">\xd0\x9f\xd0\xb0\xd1\x80\xd1\x82\xd0\xbd\xd0\xb5\xd1\x80\xd0\xb0\xd0\xbc</a></li>\n                    <li><a href="/info/agreement">\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c\xd1\x81\xd0\xba\xd0\xbe\xd0\xb5 \xd1\x81\xd0\xbe\xd0\xb3\xd0\xbb\xd0\xb0\xd1\x88\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5</a></li>

b = b"\xd0\x9f\xd0\xb0\xd1\x80\xd1\x82\xd0\xbd\xd0\xb5\xd1\x80\xd0\xb0\xd0\xbc \xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c\xd1\x81\xd0\xba\xd0\xbe\xd0\xb5 \xd1\x81\xd0\xbe\xd0\xb3\xd0\xbb\xd0\xb0\xd1\x88\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5"

b.decode("utf-8") # -> 'Партнерам Пользовательское соглашение'

R
raw1, 2018-05-08
@raw1

Everything is very simple. Sumblime text 3 itself does not support Russian text output to the console

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question