osc/research/cmip6/dl_utils/download_link_fetcher.py

21 lines
689 B
Python
Raw Normal View History

2025-05-28 19:16:17 +08:00
import pymysql
import os
import json
scripts_path = r'C:/Users/Fenoglia/Downloads/cmip6-scripts'
EOF_FLAG_STR = 'EOF--dataset.file.url.chksum_type.chksum'
if __name__ == '__main__':
db = pymysql.connect(host='39.101.194.63', port=23306,
user='root', passwd='passok123A', db='jd_data', charset='utf8mb4')
cursor = db.cursor()
SQL_SELECT = "SELECT url FROM jd_data.cmip6_search_result WHERE id IS NOT NULL "
cursor.execute(SQL_SELECT)
for line in cursor.fetchall():
url = line[0]
if url:
if url.startswith("http"):
print(url)
else:
print(json.loads(url)[0])
db.close()