|
我用下面这段代码下载数据,代码是earth data 官网给出的,但是我没操作成功。。我要下载的数据的链接是逐月的链接,比如2000年1、2、3月的数据连接:
https://hydro1.gesdisc.eosdis.na ... 0_M.A200001.021.nc4
https://hydro1.gesdisc.eosdis.na ... 0_M.A200002.021.nc4
https://hydro1.gesdisc.eosdis.na ... 0_M.A200003.021.nc4
等等
代码如下:
# Set the URL string to point to a specific data URL. Some generic examples are: # https://servername/data/path/file
# https://servername/opendap/path/file[.format[?subset]]
# https://servername/daac-bin/OTF/HTTP_services.cgi?KEYWORD=value[&KEYWORD=value]
URL = 'your_URL_string_goes_here'
# Set the FILENAME string to the data file name, the LABEL keyword value, or any customized name.
FILENAME = 'your_filename_string_goes_here' # 假如命名为 test123
import requests
result = requests.get(URL)
try:
result.raise_for_status()
f = open(FILENAME,'wb')
f.write(result.content)
f.close()
print('contents of URL written to '+FILENAME)
except:
print('requests.get() returned an error code '+str(result.status_code))
请教以下几个问题:
(1)代码中的“URL”应该怎么填?尽管有说明,很惭愧,我没看懂
(2)代码中的“FILENAME”应该是什么格式(或者说后缀是什么?)
(3)下载的数据放在什么地方了?
(4)如何打开下载的数据?
|
|