批量下载https://asdc.larc.nasa.gov/data/CERES/SSF/Aqua-FM3-MODIS_Edition4A/2022/02/文件的代码
时间: 2023-04-08 17:02:44 浏览: 194
文件下载的代码
以下是一个 Python 代码示例,可以批量下载 https://asdc.larc.nasa.gov/data/CERES/SSF/Aqua-FM3-MODIS_Edition4A/2022/02/ 目录下的所有文件:
```python
import requests
import os
url_prefix = "https://asdc.larc.nasa.gov/data/CERES/SSF/Aqua-FM3-MODIS_Edition4A/2022/02/"
save_dir = "/path/to/save/directory/"
# 获取目录下所有文件名
response = requests.get(url_prefix)
file_names = [line.split('"')[1] for line in response.text.split("\n") if ".hdf" in line]
# 下载文件
for file_name in file_names:
url = url_prefix + file_name
save_path = os.path.join(save_dir, file_name)
response = requests.get(url)
with open(save_path, "wb") as f:
f.write(response.content)
```
希望这个代码能够帮到你!
阅读全文