I
I
Ilyusha Prokopiev2019-05-14 21:30:27
Python
Ilyusha Prokopiev, 2019-05-14 21:30:27

How to decode string in python?

The task is following: to receive the description of a film from kinopoisk. The evil film search, unfortunately, does not provide its own API. I had to look for a homemade one, I found this one: kinopoiskpy
I write the following code:

from kinopoisk.movie import Movie
movie = Movie(id=843650)
movie.get_content('main_page')
plot = movie.plot
print(plot)

I get:
pћs ° ° € € € € € ‹‹ ‹Н ... С р Р‹ ‹Рєrѕr ° ° r‹ Рњ С ‚smarn μr "ruprno Ryo Ryes ·r · · · · · Р¶ жооооооооооооооооооооооооооооооооооооооооооооооооооооооооооооооо Сђ Нђ на на‹ ° p · s ° ° Р ± r ѕsmun ° С ° С ° ѕ ‹PRIS ‹rno ryr" r ° ° ° С ‹rno ryrѕr¶rμrμrμrѕr С.1rіrіr €s ђ ђ · € € € € € · € ° own ‹Рј РґРμРNoствиям РјРѕРіСѓС‰РμствРμРЅРЅРѕРіРѕ титана Таноса. RџRѕSЃR "Rμ RЅR Röhr ° ± RѕR" RμRμ RјR ° SЃS € S,R ° F ± RЅRѕRNo Ryo S,SЂR RіRoS ° F ± ‡ RμSЃRєRѕRNo RoS,RІS <PI RoSЃS,RѕSЂRoRo RѕRЅRo RЅRμ RјRѕRіSѓS, RґRѕRїSѓSЃS,RoS,SЊ RѕS € РёР±РєСѓ.
"Incorrect encoding is a simple matter", I think and add to the code:
plot = movie.plot.encode('cp1251', 'ignore').decode('utf-8', 'ignore')

I get:
Surviving... the members of the Avenger team and and... the allies must develop a new plan that will help to resist the destructive effects of the mighty titan Thanos. After the most massive and tragic battle in history, they can't make a mistake.
Better, but I definitely wouldn’t go to a movie with such a description)
If you remove ignore, then errors fly out.
What to do? How to be?
Thank you all in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question