SABER/TIMED卫星数据下载需要科学上网
import requests
from bs4 import BeautifulSoup
import os
def download(url):
proxies = {'http': 'http://127.0.0.1:7890', 'https': 'http://127.0.0.1:7890'} # 科学上网接口
headers = {'User-Agent': 'curl/7.29.0'}
myfile = requests.get(url, proxies=proxies, headers=headers)
if myfile.status_code == 200:
soup = BeautifulSoup(myfile.text, "html.parser")
lists = soup.get_text().split()
result = [lists[i].split(".nc")[0] + ".nc" for i in range(len(lists)) if "02.08.nc" in lists[i]]
for file_name in result:
if not os.path.exists(file_name):
url_nc = url + file_name
myfile = requests.get(url_nc, proxies=proxies, headers=headers)
open(file_name, 'wb').write(myfile.content)
if __name__ == "__main__":
for i in range(1, 366):
idays = str(i).zfill(3)
url = 'https://data.gats-inc.com/saber/Version2_0/Level2A/2021/' + idays + "/"
download(url)