天气API接口:
天气API接口是一种用于获取实时或预报天气信息的应用程序编程接口(API)。开发者可以使用这种接口在他们的应用程序或网站上集成天气查询功能,比如查询某个地区的当前温度、降水量、风速等数据。
通常,你需要向提供天气服务的第三方提供商(如链接: 天气API )发送HTTP请求,包含必要的参数(如城市名、API密钥),API会返回JSON或XML格式的数据。处理这些数据后,你可以将其展示给用户。
使用天气API的一般步骤:
-  注册并获取API key:首先需要在服务商网站 天气API注册,并获取到一个唯一的API密钥。 
  
-  发送GET或POST请求:构造URL,包括API地址和查询参数。 
const getWeather = () => {
  axios({
    method: "get",
    url: `http://gfeljm.tianqiapi.com/api?unescape=1&version=v91&appid=xx&appsecret=xx&city=${searchCity.value}`,
    adapter: jsonpAdapter,
  })
    .then((response) => {
      weatherList.value = response.data.data;
    })
    .catch(() => {
      console.log("7日天气查询失败");
    });
  axios({
    method: "get",
    url: `http://v0.yiketianqi.com/api?unescape=1&version=v61&appid=xx&appsecret=xx&city=${searchCity.value}`,
    adapter: jsonpAdapter,
  })
    .then((response) => {
      todayWeather.value = response.data;
    })
    .catch(() => {
      console.log("当日天气查询失败");
    });
};
- 解析响应:解析接收到的JSON或XML数据,提取所需天气信息。
const todayWeather = ref<{}>({
  update_time: "",
  wea: "",
  tem: "",
  tem1: "",
  tem2: "",
  tem_night: "",
  tem_day: "",
});
- 更新应用状态:将数据显示在你的应用界面上。














![PolarCTF靶场[web]file、ezphp WP](https://i-blog.csdnimg.cn/direct/803f6fb8e78743a8b63fe8872ca37e68.png)




