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 www.kaggle.com/quora/question-pairs-dataset

enter image description here

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

import requests, zipfile, io
r = requests.get("https://www.kaggle.com/quora/question-pairs-dataset/download")
z = zipfile.ZipFile(io.BytesIO(r.content))
z.extractall(os.getcwd())

I get the error

Traceback (most recent call last):
  File "C:UsersuDocumentsMathsCodeVariational Auto EncodersVAE_text_generation.py", line 33, in <module>
    z = zipfile.ZipFile(io.BytesIO(r.content))
  File "C:UsersuAppDataLocalProgramsPythonPython39libzipfile.py", line 1257, in __init__
    self._RealGetContents()
  File "C:UsersuAppDataLocalProgramsPythonPython39libzipfile.py", 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