Wrong encoding when downloading excel file using python 3. How to fix?

0 like 0 dislike
52 views
Script code:
import requests file = requests.get("https://login:pass@pricelabs.yandex.ru/export/myshop@yandex.ru/myshop/prices.xls") f = open("priceRF.xls", "wb") f.write(file.text.encode('cp65001')) f.close() print("Done!")


File comes.
But inside gibberish: PPP response

csv preserves, Russian characters are being read in:
f = open("priceRF.csv", "w") f.write(file.text)


But fundamentally to .xls

Please help
by | 52 views

2 Answers

0 like 0 dislike
instead of:
> f.write(file.text.encode('cp65001'))
something like:
> f.write(file.content)
by
0 like 0 dislike
Thank you, it works.
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
3 answers
0 like 0 dislike
4 answers
0 like 0 dislike
2 answers
110,608 questions
257,187 answers
0 comments
40,796 users