Hello,
You can simply pass the URL of the granule that you wish to access into the requests.get() function, but that must be stored into a variable to be written to a file, like so:
import requests
# URL of the file to be downloaded
url = "https://data.gesdisc.earthdata.nasa.gov/data/OCO2_DATA/OCO2_L2_Standard.11r/2014/249/oco2_L2StdND_00964a_140906_B11006r_230325051042.h5"
# Perform the GET request
response = requests.get(url)
filename = url.split('/')[-1] # Extracts the file name from the URL
with open(filename, 'wb') as file:
file.write(response.content)
You can simply pass the URL of the granule that you wish to access into the requests.get() function, but that must be stored into a variable to be written to a file, like so:
import requests
# URL of the file to be downloaded
url = "https://data.gesdisc.earthdata.nasa.gov/data/OCO2_DATA/OCO2_L2_Standard.11r/2014/249/oco2_L2StdND_00964a_140906_B11006r_230325051042.h5"
# Perform the GET request
response = requests.get(url)
filename = url.split('/')[-1] # Extracts the file name from the URL
with open(filename, 'wb') as file:
file.write(response.content)
Statistics: Posted by cbattisto — Wed Mar 20, 2024 12:02 pm America/New_York