数据来着中国天气网
equalizer 累计使用:3312
请求地址 https://free.wqwlkj.cn/wqwlapi/weather.php
请求示例 https://free.wqwlkj.cn/wqwlapi/weather.php?city=上海
请求方式 GET
返回格式 JSON
{
"code": 1,
"text": "获取成功",
"data": {
"city": "上海",
"cityEnglish": "shanghai",
"temp": 26,
"tempn": 28,
"weather": "小雨转阴",
"wind": "东南风转西风",
"windSpeed": "3-4级",
"time": "2025-06-13 08:00",
"warning": {
"windSpeed": 12,
"wind": "大雾",
"color": "黄色",
"warning": "上海中心气象台2025年06月13日01时30分发布大雾黄色预警[Ⅲ级/较重]:预计未来12小时内本市大部地区将出现能见度小于500米的雾,局部地区能见度小于200米,请注意防范低能见度对道路交通的不利影响。(预警信息来源:国家预警信息发布中心)",
"time": "2025-06-14 01:30:00"
},
"current": {
"city": "上海",
"cityEnglish": "shanghai",
"humidity": "97%",
"wind": "东北风",
"windSpeed": "1级",
"visibility": "5km",
"weather": "阴",
"weatherEnglish": "Overcast",
"temp": 24.7,
"fahrenheit": 76.5,
"air": 21,
"air_pm25": 21,
"date": "06月13日(星期五)",
"time": "05:50",
"image": "https://free.wqwlkj.cn/wqwlapi/data/weather/image/阴.png"
},
"living": [
{
"name": "路况指数",
"index": "湿滑",
"tips": "路面湿滑,车辆易打滑,减慢车速。"
},
{
"name": "晨练指数",
"index": "不宜",
"tips": "有较强降水,建议在室内做适当锻炼。"
},
{
"name": "夜生活指数",
"index": "较不适宜",
"tips": "建议夜生活最好在室内进行。"
},
{
"name": "感冒指数",
"index": "较易发",
"tips": "天凉,湿度大,较易感冒。"
},
{
"name": "逛街指数",
"index": "较不宜",
"tips": "有降水,出门需带雨具并防暑。"
},
{
"name": "空气污染扩散条件指数",
"index": "良",
"tips": "气象条件有利于空气污染物扩散。"
},
{
"name": "旅游指数",
"index": "适宜",
"tips": "有降水,温度适宜,不要错过出游机会。"
},
{
"name": "舒适度指数",
"index": "舒适",
"tips": "白天温度宜人,风力不大。"
},
{
"name": "啤酒指数",
"index": "适宜",
"tips": "天气炎热,可适量饮用啤酒,不要过量。"
},
{
"name": "划船指数",
"index": "不适宜",
"tips": "天气不好,建议选择别的娱乐方式。"
},
{
"name": "太阳镜指数",
"index": "不需要",
"tips": "白天能见度差不需要佩戴太阳镜"
},
{
"name": "紫外线强度指数",
"index": "最弱",
"tips": "辐射弱,涂擦SPF8-12防晒护肤品。"
},
{
"name": "风寒指数",
"index": "无",
"tips": "温度未达到风寒所需的低温,稍作防寒准备即可。"
},
{
"name": "穿衣指数",
"index": "舒适",
"tips": "建议穿长袖衬衫单裤等服装。"
},
{
"name": "放风筝指数",
"index": "不宜",
"tips": "天气不好,不适宜放风筝。"
},
{
"name": "空调开启指数",
"index": "较少开启",
"tips": "体感舒适,不需要开启空调。"
},
{
"name": "钓鱼指数",
"index": "不宜",
"tips": "天气不好,有风,不适合垂钓。"
},
{
"name": "晾晒指数",
"index": "不宜",
"tips": "降水可能会淋湿衣物,请选择在室内晾晒。"
},
{
"name": "洗车指数",
"index": "不宜",
"tips": "有雨,雨水和泥水会弄脏爱车。"
},
{
"name": "心情指数",
"index": "较差",
"tips": "雨水可能会使心绪无端地挂上轻愁。"
},
{
"name": "中暑指数",
"index": "无中暑风险",
"tips": "天气舒适,对易中暑人群来说非常友善。"
},
{
"name": "交通指数",
"index": "较差",
"tips": "有降水且路面湿滑,注意控制车速。"
},
{
"name": "约会指数",
"index": "较不适宜",
"tips": "建议尽量不要去室外约会。"
},
{
"name": "运动指数",
"index": "较不宜",
"tips": "有降水,推荐您在室内进行休闲运动。"
},
{
"name": "过敏指数",
"index": "不易发",
"tips": "除特殊体质,无需担心过敏问题。"
},
{
"name": "美发指数",
"index": "适宜",
"tips": "风力较大容易弄脏头发,注意清洁。"
},
{
"name": "雨伞指数",
"index": "带伞",
"tips": "有降水,带雨伞,短期外出可收起雨伞。"
},
{
"name": "防晒指数",
"index": "弱",
"tips": "涂抹8-12SPF防晒护肤品。"
},
{
"name": "化妆指数",
"index": "去油",
"tips": "请选用露质面霜打底,水质无油粉底霜。"
},
{
"name": "干燥指数",
"index": "适宜",
"tips": "风速偏大,湿度条件较好,皮肤可做日常护理,注意预防风大带来的皮肤粗糙问题。"
}
]
}
}
参数名称 | 是否必需 | 参数说明 |
---|---|---|
city |
否 | 需要查询的城市 |
type |
否 | 可选json text 默认就送 |
参数名称 | 参数类型 | 参数说明 |
---|---|---|
code |
integer |
1成功其他失败 |
text |
string |
返回结果 |
data |
string |
返回数据 |
更新时间 2023-03-11 18:04:07
状态码 | 状态说明 |
---|---|
400 | 请求错误 |
403 | 请求被服务器拒绝 |
404 | 请求服务器失败 |
500 | 服务器错误 |
503 | 服务器维护 |
GET方法
$url = 'https://free.wqwlkj.cn/wqwlapi/weather.php';
$data = '?city=上海';
$get = $url.$data;
$result = file_get_contents($get);
if ($result) {
//成功
echo $result;
} else {
//失败
}
POST方法
$url = 'https://free.wqwlkj.cn/wqwlapi/weather.php';
$data = array(
  'city' => '上海',
);
$data = http_build_query($data);
$option = array('http'=>array('method'=>'POST','content'=>$data));
$context = stream_context_create($option);
$result = file_get_contents($url,false,$context);
if ($result) {
//成功
echo $result;
} else {
//失败
}
GET方法
var url = "https://free.wqwlkj.cn/wqwlapi/weather.php"
var data = "?city=上海"
var xhrGet = new XMLHttpRequest();
xhrGet.open('GET', url + data, true);
xhrGet.send();
xhrGet.onreadystatechange = function() {
if (xhrGet.readyState == 4 && xhrGet.status == 200) {
//成功
var result = xhrGet.responseText;
console.log(result);
} else {
//失败
}
};
POST方法
var url = "https://free.wqwlkj.cn/wqwlapi/weather.php"
var data = "city=上海"
var xhrPost = new XMLHttpRequest();
xhrPost.open('POST', url, true);
xhrPost.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhrPost.send(data);
xhrPost.onreadystatechange = function() {
if (xhrPost.readyState == 4 && xhrPost.status == 200) {
//成功
var result = xhrPost.responseText;
console.log(result);
} else {
//失败
}
};
GET方法
new Thread(){
public void run() {
String path = "https://free.wqwlkj.cn/wqwlapi/weather.php";
String data = "?city=上海";
try {
URL url = new URL(path + data);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
int code = connection.getResponseCode();
if (code == 200) {
//成功
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader bufferedreader = new BufferedReader(isr);
String string;
StringBuilder stringbuilder = new StringBuilder();
while ((string = bufferedreader.readLine()) != null) {
stringbuilder.append(string);
}
final String result = stringbuilder.toString();
System.out.println(result);
} else {
//失败
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}}.start();
POST方法
new Thread(){
public void run() {
String path = "https://free.wqwlkj.cn/wqwlapi/weather.php";
String data = "city=上海";
try {
URL url = new URL(path);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.getOutputStream().write(data.getBytes());
int code = connection.getResponseCode();
if (code == 200) {
//成功
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader bufferedreader = new BufferedReader(isr);
String string;
StringBuilder stringbuilder = new StringBuilder();
while ((string = bufferedreader.readLine()) != null) {
stringbuilder.append(string);
}
final String result = stringbuilder.toString();
System.out.println(result);
} else {
//失败
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}}.start();
GET方法
url="https://free.wqwlkj.cn/wqwlapi/weather.php"
data=url.."?city=上海"
Http.get(data,function(code,content,data)
if code==200 then
--成功
print(content)
else
--失败
end
end)
POST方法
url="https://free.wqwlkj.cn/wqwlapi/weather.php"
data="city=上海"
Http.post(url,data,function(code,content,data)
if code==200 then
--成功
print(content)
else
--失败
end
end)
GET方法
变量 网络GET操作 为 网络操作 = 创建 网络操作()
变量 GET数据 为 文本型 = "?city=上海"
网络GET操作.取网页源码("https://free.wqwlkj.cn/wqwlapi/weather.php" + GET数据)
事件 网络GET操作:取网页源码结束(结果 为 文本型,cookie 为 文本型)
//成功
调试输出(结果)
结束 事件
事件 网络GET操作:取网页源码失败(响应码 为 文本型)
//失败
结束 事件
POST方法
变量 网络POST操作 为 网络操作 = 创建 网络操作()
变量 POST数据 为 文本型 = "city=上海"
网络POST操作.发送数据("https://free.wqwlkj.cn/wqwlapi/weather.php",POST数据)
事件 网络POST操作:发送数据结束(结果 为 文本型,cookie 为 文本型)
//成功
调试输出(结果)
结束 事件
事件 网络POST操作:发送数据失败(响应码 为 文本型)
//失败
结束 事件
GET方法
s url="https://free.wqwlkj.cn/wqwlapi/weather.php"
s data="?city=上海"
ss(url+data,get)
t(){
hs(get,result)
f(result!=null){
//成功
syso(result)
}else{
//失败
}
}
POST方法
s url="https://free.wqwlkj.cn/wqwlapi/weather.php"
s data="city=上海"
t(){
hs(url,data,"utf-8",result)
f(result!=null){
//成功
syso(result)
}else{
//失败
}
}
反馈时间 | 反馈接口 | 反馈内容 | 反馈者IP |
---|