Home > database >  Download data.zip programmatically for "Loophole-free Bell-inequality violation using electron
Download data.zip programmatically for "Loophole-free Bell-inequality violation using electron

Time:10-17

I would like to create a gist or a Jupyter notebook analyzing the data located at enter image description here

which right-clicking to copy-paste the link tells me it associated with the URL https://data.4tu.nl/ndownloader/files/24056582. If I copy-paste this URL into Firefox it downloads the file. I would like to do this with Python.

I figured I would try making a request to that link with the following.

import requests
requests.get('https://data.4tu.nl/ndownloader/files/24056582')

But the above did not seem to download data.zip as desired. How can I use Python to programmatically download data.zip into the local path of my Python script?

CodePudding user response:

Try:

import requests

r = requests.get("https://data.4tu.nl/ndownloader/files/24056582")

with open("data.zip", "wb") as f_out:
    f_out.write(r.content)

This downloads the data.zip:

-rw-r--r-- 1 root root 152913 okt 17 00:35 data.zip
  • Related