简体   繁体   中英

save a response from an api that returns csv file

I am developing a script that queries a REST API that returns a csv file, my problem is that I can not save this file locally on my machine.

Following my request API returns a non-encoded form (as shown in the attached picture)

PS:- I develop my script in python

1个

i would like to have a solution to save csv file localy, on a specific path

Try writing the binary REST API response to a file:

from requests import get

resp = get("https://example.com/csv_api")

with open("test.csv", 'wb') as f:
    f.write(resp.content)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM