I'm downloading a zip file via API with this request:
it's supposed that my "response" variable now it's the zip file, however when I try to open, I can't, it's like it doesn't exist. How can be unzipped and extract the .txt file inside?
Hi @Josep, I dont know if that is correct. The API response might be a data stream, you will need convert it into a file first, then attempt de-compress.
import requests r = requests.get("<URL>", stream=True) with open("<filepath>", 'wb') as f: for chunk in r.iter_content(128): f.write(chunk)
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!