How to download a file from Kaggle and work on it in python

I want to download a dataset from Kaggle in python then work on it. When I click the download button say on this page

enter image description here

my browser is loading a zip file. However if I do in python

import requests, zipfile, io
r = requests.get("")
z = zipfile.ZipFile(io.BytesIO(r.content))

I get the error

Traceback (most recent call last):
  File "C:UsersuDocumentsMathsCodeVariational Auto", line 33, in <module>
    z = zipfile.ZipFile(io.BytesIO(r.content))
  File "", line 1257, in __init__
  File "", line 1324, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

Any solution for getting the file from the url – unzip if needed – and get the name of the downloaded file so as to be able to work on it ?

Read more here: Source link