As far as I know, queries do not provide a function that saves the contents to a file.
import requests with open('local-file', 'wb') as f: r = requests.get('url', stream=True) f.writelines(r.iter_content(1024))
See request.Response.iter_content documentation .
iter_content (chunk_size = 1, decode_unicode = False)
Iterates according to the response. When thread = True is set to a query, this avoids reading content in memory at the same time for large responses. The chunk size is the number of bytes that it should read into memory. This is not necessarily the length of each element returned as decoding may take place.
source share