Files
gofly-platform-services/zlt-business/order-center/src/main/resources/scripts/test-open-meteo.sh
T

44 lines
1.9 KiB
Bash

#!/bin/bash
# =============================================
# Open-Meteo 天气API快速测试脚本
# =============================================
echo "=========================================="
echo "Open-Meteo 天气API测试"
echo "=========================================="
echo ""
# 测试1:北京天气
echo "【测试1】获取北京天气..."
curl -s "https://api.open-meteo.com/v1/forecast?latitude=39.9042&longitude=116.4074&current=temperature_2m,relative_humidity_2m,precipitation,weather_code,cloud_cover,pressure_msl,wind_speed_10m,wind_direction_10m&timezone=Asia/Shanghai" | jq '.'
echo ""
echo "----------------------------------------"
echo ""
# 测试2:上海天气
echo "【测试2】获取上海天气..."
curl -s "https://api.open-meteo.com/v1/forecast?latitude=31.2304&longitude=121.4737&current=temperature_2m,relative_humidity_2m,precipitation,weather_code,cloud_cover,pressure_msl,wind_speed_10m,wind_direction_10m&timezone=Asia/Shanghai" | jq '.'
echo ""
echo "----------------------------------------"
echo ""
# 测试3:广州天气
echo "【测试3】获取广州天气..."
curl -s "https://api.open-meteo.com/v1/forecast?latitude=23.1291&longitude=113.2644&current=temperature_2m,relative_humidity_2m,precipitation,weather_code,cloud_cover,pressure_msl,wind_speed_10m,wind_direction_10m&timezone=Asia/Shanghai" | jq '.'
echo ""
echo "----------------------------------------"
echo ""
# 测试4:黄山天气
echo "【测试4】获取黄山天气..."
curl -s "https://api.open-meteo.com/v1/forecast?latitude=30.1333&longitude=118.1673&current=temperature_2m,relative_humidity_2m,precipitation,weather_code,cloud_cover,pressure_msl,wind_speed_10m,wind_direction_10m&timezone=Asia/Shanghai" | jq '.'
echo ""
echo "----------------------------------------"
echo ""
echo "测试完成!"
echo ""
echo "如果看到天气数据,说明Open-Meteo API可以正常访问。"
echo "如果没有安装jq,可以去掉 '| jq' 查看原始JSON数据。"