0

I have the following link. how can save it to excel file in python

link="http://www.tsetmc.com/tsev2/excel/MarketWatchPlus.aspx?deven=0"

I tried to download:

import requests
dls = "http://www.tsetmc.com/tsev2/excel/MarketWatchPlus.aspx?deven=0"
resp = requests.get(dls)

output = open('test.xls', 'wb')
output.write(resp.content)
output.close()

but the saving test.xls has the following error:

Error! C:\Users\Relief International\test.xls is not UTF-8 encoded
Saving disabled.
See Console for more details.

how do I make python download the mentioned link as an excel file?

AlexisG
  • 2,476
  • 3
  • 11
  • 25
sadiqkhan
  • 11
  • 1
  • Are you running this in a Jupyter notebook? If so, please see this: [Error! blahfile is not UTF-8 encoded. Saving disabled](https://stackoverflow.com/q/61114350/2745495). (Always mention the env where you are running the Python code.) – Gino Mempin Sep 08 '20 at 03:11

1 Answers1

0

The code works fine for me.

The error comes from Jupyter, which doesn't know how to display the data. But the file should be correctly downloaded.

AlexisG
  • 2,476
  • 3
  • 11
  • 25