Skip to content

Instantly share code, notes, and snippets.

@kagermanov27
Created May 19, 2022 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kagermanov27/9e162f06884a881f7b24926625ac1396 to your computer and use it in GitHub Desktop.
Save kagermanov27/9e162f06884a881f7b24926625ac1396 to your computer and use it in GitHub Desktop.
## Download and guess the file format
r = requests.get(link)
extension = mimetypes.guess_extension(r.headers.get('content-type', '').split(';')[0])
if not extension == ".html":
with open("datasets/test/{}/{}.{}".format(self.query.q, latest_file_name, extension or 'jpg'), 'wb') as f:
f.write(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment