| 参数名称 | 类型 | 必填 | 说明 |
| page | int | 否 | 城市分页 |
| 参数名称 | 类型 | 说明 | |
| cityid | int | 城市ID | |
| city | string | 城市名称 | |
| province | string | 上级省份 | |
| lon | decimal | 坐标经度 | |
| lat | decimal | 坐标纬度 |
require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/weather/city";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
$body = json_decode($result["body"], TRUE);
$status_code = $body["status"];
if ($status_code == "200") {
var_dump($body["result"]);
}else
var_dump($body);
}else
echo "发送请求失败";
/**
* 主函数
* @param args
*/
public static void main(String args[])
{
//请求地址设置
String url = "http://open.liupai.net/weather/city";
//请求方法设置
String requestMethod = "POST";
//请求头部设置
Map<String, String> headers = new HashMap<String, String>();
//请求参数设置
Map<String, String> params = new HashMap<String, String>();
params.put("appkey", "yourappsecret");
String result = proxyToDesURL(requestMethod, url, headers, params);
if (result != null) {
JSONObject jsonObject = JSONObject.parseObject(result);
String status_code = jsonObject.getString("status");
if (status_code.equals("200")) {
System.out.println("请求成功:" + jsonObject.getString("result"));
} else {
System.out.println("请求失败:" + jsonObject.getString("msg"));
}
} else {
System.out.println("发送请求异常");
}
}#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/weather/city"
headers = None
params = {
"appkey" : "yourappsecret"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print("请求成功:%s" % (body,))
else:
print("请求失败: %s" % (body,){
"status": 200,
"msg": "OK",
"result": [
{
"cityid": "2",
"city": "北京市",
"province": "北京市",
"lon": "116.4071121216",
"lat": "39.9041366577"
},
{
"cityid": "3",
"city": "北京市朝阳区",
"province": "北京市",
"lon": "116.4432449341",
"lat": "39.9212226868"
},
{
"cityid": "4",
"city": "北京市通州区",
"province": "北京市",
"lon": "116.6564712524",
"lat": "39.9101066589"
},
{
"cityid": "5",
"city": "昌平区",
"province": "北京市",
"lon": "116.2312774658",
"lat": "40.2205276489"
},
{
"cityid": "6",
"city": "顺义区",
"province": "北京市",
"lon": "116.6554260254",
"lat": "40.1305656433"
},
{
"cityid": "7",
"city": "怀柔区",
"province": "北京市",
"lon": "116.6319274902",
"lat": "40.3162765503"
},| 参数名称 | 类型 | 必填 | 说明 |
| city | string | 是 | 城市ID |
| 参数名称 | 类型 | 说明 | |
| city | array | 城市数据 | |
| cityId | int | 城市ID | |
| counname | string | 国家名称 | |
| ianatimezone | string | 标准时区 | |
| name | string | 城市名称 | |
| pname | string | 上级区域名称 | |
| secondaryname | string | 二级城市名 | |
| timezone | string | 时区 | |
| condition | array | 天气实况 | |
| condition | string | 实时天气 | |
| conditionId | int | 实时天气id | |
| humidity | int | 湿度 | |
| icon | int | 天气icon | |
| pressure | int | 气压 | |
| realFeel | int | 体感温度 | |
| sunRise | string | 日出时间 | |
| sunSet | string | 日落时间 | |
| temp | int | 温度 | |
| tips | string | 一句话提示 | |
| updatetime | string | 发布时间 | |
| uvi | int | 紫外线强度 | |
| vis | int | 能见度 | |
| windDegrees | int | 风向角度 | |
| windDir | string | 风向 | |
| windLevel | decimal | 风级 | |
| windSpeed | decimal | 风速 |
require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/weather/query";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"city" => "2"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
$body = json_decode($result["body"], TRUE);
$status_code = $body["status"];
if ($status_code == "200") {
var_dump($body["result"]);
}else
var_dump($body);
}else
echo "发送请求失败";
/**
* 主函数
* @param args
*/
public static void main(String args[])
{
//请求地址设置
String url = "http://open.liupai.net/weather/query";
//请求方法设置
String requestMethod = "POST";
//请求头部设置
Map<String, String> headers = new HashMap<String, String>();
//请求参数设置
Map<String, String> params = new HashMap<String, String>();
params.put("appkey", "yourappsecret");
params.put("city", "2");
String result = proxyToDesURL(requestMethod, url, headers, params);
if (result != null) {
JSONObject jsonObject = JSONObject.parseObject(result);
String status_code = jsonObject.getString("status");
if (status_code.equals("200")) {
System.out.println("请求成功:" + jsonObject.getString("result"));
} else {
System.out.println("请求失败:" + jsonObject.getString("msg"));
}
} else {
System.out.println("发送请求异常");
}
}#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/weather/query"
headers = None
params = {
"appkey" : "yourappsecret",
"city" : "2"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print("请求成功:%s" % (body,))
else:{
"status": 200,
"msg": "OK",
"result": {
"city": {
"cityId": 3,
"counname": "中国",
"ianatimezone": "Asia/Shanghai",
"name": "北京市朝阳区",
"pname": "北京市",
"secondaryname": "北京市",
"timezone": "8"
},
"condition": {
"condition": "阴",
"conditionId": "85",
"humidity": "91",
"icon": "2",
"pressure": "1024",
"realFeel": "1",
"sunRise": "2020-11-21 07:06:00",
"sunSet": "2020-11-21 16:54:00",
"temp": "3",
"tips": "今天有雪,天气阴冷,穿暖和点吧!",
"updatetime": "2020-11-21 18:20:08",
"uvi": "1",
"vis": "11159",
"windDegrees": "45",
"windDir": "东北风",
"windLevel": "2",
"windSpeed": "1.9"
}
}
}| 参数名称 | 类型 | 必填 | 说明 |
| city | int | 是 | 城市ID |
| 参数名称 | 类型 | 说明 | |
| code | int | 指数代码 | |
| day | string | 日期 | |
| desc | string | 描述 | |
| level | int | 等级 | |
| name | string | 指数名称 | |
| status | string | 状态 | |
| updatetime | string | 更新时间 |
require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/weather/index";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"city" => "2"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
$body = json_decode($result["body"], TRUE);
$status_code = $body["status"];
if ($status_code == "200") {
var_dump($body["result"]);
}else
var_dump($body);
}else
echo "发送请求失败";
/**
* 主函数
* @param args
*/
public static void main(String args[])
{
//请求地址设置
String url = "http://open.liupai.net/weather/index";
//请求方法设置
String requestMethod = "POST";
//请求头部设置
Map<String, String> headers = new HashMap<String, String>();
//请求参数设置
Map<String, String> params = new HashMap<String, String>();
params.put("appkey", "yourappsecret");
params.put("city", "2");
String result = proxyToDesURL(requestMethod, url, headers, params);
if (result != null) {
JSONObject jsonObject = JSONObject.parseObject(result);
String status_code = jsonObject.getString("status");
if (status_code.equals("200")) {
System.out.println("请求成功:" + jsonObject.getString("result"));
} else {
System.out.println("请求失败:" + jsonObject.getString("msg"));
}
} else {
System.out.println("发送请求异常");
}
}#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/weather/index"
headers = None
params = {
"appkey" : "yourappsecret",
"city" : "2"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print("请求成功:%s" % (body,))
else:
print("请求失败: %s" % (body,))
else:
print("发送请求失败"){
"status": 200,
"msg": "OK",
"result": {
"city": {
"cityId": 2,
"counname": "中国",
"ianatimezone": "Asia/Shanghai",
"name": "北京市",
"pname": "北京市",
"secondaryname": "北京市",
"timezone": "8"
},
"liveIndex": {
"2024-07-10": [
{
"code": 28,
"day": "2024-07-10",
"desc": "气压小幅波动,可能会影响鱼儿的进食。",
"level": "8",
"name": "钓鱼指数",
"status": "较适宜",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 21,
"day": "2024-07-10",
"desc": "辐射强,请涂擦SPF大于15、PA+防晒护肤品。",
"level": "4",
"name": "紫外线指数",
"status": "强",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 7,
"day": "2024-07-10",
"desc": "建议用露质面霜打底,水质无油粉底霜,透明粉饼,粉质胭脂。",
"level": "10",
"name": "化妆指数",
"status": "控油",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 32,
"day": "2024-07-10",
"desc": "未来一段时间的气象条件下,可能会有小部分人出现过敏症状。体质敏感的人尤其需要注意应对。对于有过敏史的人,建议适当采取相应的防过敏措施,比如戴口罩出门。",
"level": "3",
"name": "息斯敏过敏指数",
"status": "较易发",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 5,
"day": "2024-07-10",
"desc": "天气较好,路面干燥,交通气象条件良好,车辆可以正常行驶。",
"level": "1",
"name": "交通指数",
"status": "良好",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 12,
"day": "2024-07-10",
"desc": "感冒较易发生,干净整洁的环境和清新流通的空气都有利于降低感冒的几率,体质较弱的童鞋们要特别加强自我保护。",
"level": "3",
"name": "感冒指数",
"status": "较易发",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 26,
"day": "2024-07-10",
"desc": "空气轻度污染,不宜在户外运动。",
"level": "17",
"name": "运动指数",
"status": "不适宜",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 20,
"day": "2024-07-10",
"desc": "天气炎热,衣物轻薄透气,室外注意遮阳避暑,室内酌情添加空调衫,不建议在露天场所逛街。",
"level": "1",
"name": "穿衣指数",
"status": "炎热",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 14,
"day": "2024-07-10",
"desc": "天气较好,温度较高,天气较热,但有微风相伴,还是比较适宜旅游的,不过外出时要注意防暑防晒哦!",
"level": "2",
"name": "旅游指数",
"status": "较适宜",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 17,
"day": "2024-07-10",
"desc": "较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。",
"level": "5",
"name": "洗车指数",
"status": "较适宜",
"updatetime": "2024-07-10 19:06:03"
},
{
"code": 18,
"day": "2024-07-10",
"desc": "气象条件对空气污染物稀释、扩散和清除无明显影响,易感人群应适当减少室外活动时间。",
"level": "3",
"name": "空气污染扩散指数",
"status": "中",
"updatetime": "2024-07-10 19:06:03"
}
]
}
}
}| 参数名称 | 类型 | 必填 | 说明 |
| city | int | 是 | 城市ID |
| 参数名称 | 类型 | 说明 | |
| city | array | 城市数据 | |
| cityId | int | 城市ID | |
| counname | string | 国家名称 | |
| ianatimezone | string | 标准时区 | |
| name | string | 城市名称 | |
| pname | string | 上级区域名称 | |
| secondaryname | string | 二级城市名 | |
| timezone | string | 时区 | |
| hourly | array | 每小时天气情况 | |
| condition | string | 天气状况 | |
| conditionId | int | 天气状况id | |
| date | string | 预报日期 | |
| hour | int | 小时 | |
| humidity | int | 湿度 | |
| iconDay | int | 白天icon | |
| iconNight | int | 夜间icon | |
| pop | int | 降水概率 | |
| pressure | int | 气压 | |
| qpf | decimal | 定量降水预报(mm) | |
| realFeel | int | 体感温度 | |
| snow | int | 降雪量 | |
| temp | int | 实时温度 | |
| updatetime | string | 更新时间 | |
| uvi | int | 紫外线强度 | |
| windDegrees | int | 风向角度 | |
| windDir | string | 风向 | |
| windSpeed | decimal | 风速 | |
| windlevel | int | 风级 |
require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/weather/forecast24hours";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"city" => "2"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
$body = json_decode($result["body"], TRUE);
$status_code = $body["status"];
if ($status_code == "200") {
var_dump($body["result"]);
}else
var_dump($body);
}else
echo "发送请求失败";
/**
* 主函数
* @param args
*/
public static void main(String args[])
{
//请求地址设置
String url = "http://open.liupai.net/weather/forecast24hours";
//请求方法设置
String requestMethod = "POST";
//请求头部设置
Map<String, String> headers = new HashMap<String, String>();
//请求参数设置
Map<String, String> params = new HashMap<String, String>();
params.put("appkey", "yourappsecret");
params.put("city", "2");
String result = proxyToDesURL(requestMethod, url, headers, params);
if (result != null) {
JSONObject jsonObject = JSONObject.parseObject(result);
String status_code = jsonObject.getString("status");
if (status_code.equals("200")) {
System.out.println("请求成功:" + jsonObject.getString("result"));
} else {
System.out.println("请求失败:" + jsonObject.getString("msg"));
}
} else {
System.out.println("发送请求异常");
}
}#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/weather/forecast24hours"
headers = None
params = {
"appkey" : "yourappsecret",
"city" : "2"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print("请求成功:%s" % (body,))
el{
"status": 200,
"msg": "OK",
"result": {
"city": {
"cityId": 2,
"counname": "中国",
"ianatimezone": "Asia/Shanghai",
"name": "北京市",
"pname": "北京市",
"secondaryname": "北京市",
"timezone": "8"
},
"hourly": [
{
"condition": "阴",
"conditionId": "85",
"date": "2020-11-21",
"hour": "21",
"humidity": "76",
"iconDay": "2",
"iconNight": "2",
"pop": "40",
"pressure": "1028",
"qpf": "0.0",
"realFeel": "2",
"snow": "0",
"temp": "2",
"updatetime": "2020-11-21 21:40:14",
"uvi": "1",
"windDegrees": "45",
"windDir": "NNE",
"windSpeed": "16.20",
"windlevel": "3"
},
{
"condition": "阴",
"conditionId": "85",
"date": "2020-11-21",| 参数名称 | 类型 | 必填 | 说明 |
| city | int | 是 | 城市ID |
| 参数名称 | 类型 | 说明 | |
| city | array | 城市数据 | |
| cityId | int | 城市ID | |
| counname | string | 国家名称 | |
| ianatimezone | string | 标准时区 | |
| name | string | 城市名称 | |
| pname | string | 上级区域名称 | |
| secondaryname | string | 二级城市名 | |
| timezone | string | 时区 | |
| forecast | array | 15天气象预测 | |
| conditionDay | string | 白天天气 | |
| conditionIdDay | int | 白天天气id | |
| conditionIdNight | int | 夜间天气id | |
| conditionNight | string | 夜间天气 | |
| humidity | int | 湿度 | |
| moonphase | string | 月相 | |
| moonrise | string | 月出 | |
| moonset | string | 月落 | |
| pop | int | 降水概率 | |
| predictDate | string | 预报日期 | |
| qpf | int | 定量降水预报(mm) | |
| sunrise | string | 日出 | |
| sunset | string | 日落 | |
| tempDay | int | 白天温度 | |
| tempNight | int | 夜间温度 | |
| updatetime | string | 更新时间 | |
| uvi | int | 紫外线强度 | |
| windDegreesDay | int | 白天风向角度 | |
| windDegreesNight | int | 夜间风向角度 | |
| windDirDay | string | 白天风向 | |
| windDirNight | string | 夜间风向 | |
| windLevelDay | int | 白天风级 | |
| windLevelNight | int | 夜间风级 | |
| windSpeedDay | decimal | 白天风速 | |
| windSpeedNight | decimal | 夜间风速 |
require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/weather/forecast15days";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"city" => "2"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
$body = json_decode($result["body"], TRUE);
$status_code = $body["status"];
if ($status_code == "200") {
var_dump($body["result"]);
}else
var_dump($body);
}else
echo "发送请求失败";
/**
* 主函数
* @param args
*/
public static void main(String args[])
{
//请求地址设置
String url = "http://open.liupai.net/weather/forecast15days";
//请求方法设置
String requestMethod = "POST";
//请求头部设置
Map<String, String> headers = new HashMap<String, String>();
//请求参数设置
Map<String, String> params = new HashMap<String, String>();
params.put("appkey", "yourappsecret");
params.put("city", "2");
String result = proxyToDesURL(requestMethod, url, headers, params);
if (result != null) {
JSONObject jsonObject = JSONObject.parseObject(result);
String status_code = jsonObject.getString("status");
if (status_code.equals("200")) {
System.out.println("请求成功:" + jsonObject.getString("result"));
} else {
System.out.println("请求失败:" + jsonObject.getString("msg"));
}
} else {
System.out.println("发送请求异常");
}
}#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/weather/forecast15days"
headers = None
params = {
"appkey" : "yourappsecret",
"city" : "2"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print("请求成功:%s" % (body,))
els{
"status": 200,
"msg": "OK",
"result": {
"city": {
"cityId": 2,
"counname": "中国",
"ianatimezone": "Asia/Shanghai",
"name": "北京市",
"pname": "北京市",
"secondaryname": "北京市",
"timezone": "8"
},
"forecast": [
{
"conditionDay": "小雪",
"conditionIdDay": "14",
"conditionIdNight": "14",
"conditionNight": "小雪",
"humidity": "42",
"moonphase": "WaxingCrescent",
"moonrise": "2020-11-20 12:10:00",
"moonset": "2020-11-20 21:46:00",
"pop": "20",
"predictDate": "2020-11-20",
"qpf": "0.0",
"sunrise": "2020-11-20 07:05:00",
"sunset": "2020-11-20 16:55:00",
"tempDay": "8",
"tempNight": "-1",
"updatetime": "2020-11-20 23:06:00",
"uvi": "3",
"windDegreesDay": "225",
"windDegreesNight": "180",
"windDirDay"| 参数名称 | 类型 | 必填 | 说明 |
| city | int | 是 | 城市ID |
| 参数名称 | 类型 | 说明 | |
| content | string | 预警内容 | |
| infoid | int | 预警id | |
| level | int | 预警等级 | |
| name | string | 预警名称 | |
| pub_time | string | 发布时间 | |
| title | string | 预警标题 | |
| update_time | string | 更新时间 | |
| type | string | 预警类型 |
require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/weather/alert";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"city" => "2"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
$body = json_decode($result["body"], TRUE);
$status_code = $body["status"];
if ($status_code == "200") {
var_dump($body["result"]);
}else
var_dump($body);
}else
echo "发送请求失败";
/**
* 主函数
* @param args
*/
public static void main(String args[])
{
//请求地址设置
String url = "http://open.liupai.net/weather/alert";
//请求方法设置
String requestMethod = "POST";
//请求头部设置
Map<String, String> headers = new HashMap<String, String>();
//请求参数设置
Map<String, String> params = new HashMap<String, String>();
params.put("appkey", "yourappsecret");
params.put("city", "2");
String result = proxyToDesURL(requestMethod, url, headers, params);
if (result != null) {
JSONObject jsonObject = JSONObject.parseObject(result);
String status_code = jsonObject.getString("status");
if (status_code.equals("200")) {
System.out.println("请求成功:" + jsonObject.getString("result"));
} else {
System.out.println("请求失败:" + jsonObject.getString("msg"));
}
} else {
System.out.println("发送请求异常");
}
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/weather/alert"
headers = None
params = {
"appkey" : "yourappsecret",
"city" : "2"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print("请求成功:%s" % (body,))
else:
print("请求失败: %s" % (body,))
else:
print("发送请求失败"){
"status": 200,
"msg": "OK",
"result": {
"alert": [
{
"content": "綦江区气象台2024年7月10日21时00分发布“暴雨蓝色预警信号”,预计未来6小时内,横山镇、扶欢镇、三角镇、石角镇、安稳镇、永城镇、隆盛镇、永新镇、古南街道、三江街道、文龙街道、通惠街道、东溪镇、石壕镇、赶水镇、打通镇、丁山镇、郭扶镇、篆塘镇等镇街降雨量将达50毫米以上,并伴有雷电、短时强降水等强对流天气,请注意防范。(预警信息来源:国家预警信息发布中心)",
"infoid": 28,
"land_defense_id": "17,19,9",
"level": "蓝色",
"name": "暴雨",
"port_defense_id": "17,19,9",
"pub_time": "2024-07-10 21:13:07",
"title": "綦江区气象局发布暴雨蓝色预警[Ⅳ级/一般]",
"type": "暴雨蓝色",
"update_time": "2024-07-10 21:17:09"
},
{
"content": "綦江区气象台2024年7月10日20时50分发布“雷电黄色预警信号”,预计未来6小时内,横山镇、扶欢镇、三角镇、石角镇、安稳镇、永城镇、隆盛镇、中峰镇、永新镇、古南街道、三江街道、文龙街道、通惠街道、东溪镇、石壕镇、赶水镇、打通镇、丁山镇、郭扶镇、篆塘镇将发生雷电活动,并伴有短时强降水和阵性大风,请注意防范。(预警信息来源:国家预警信息发布中心)",
"infoid": 66,
"land_defense_id": "1,10,12",
"level": "黄色",
"name": "雷电",
"port_defense_id": "1,10,12",
"pub_time": "2024-07-10 21:02:21",
"title": "綦江区气象局发布雷电黄色预警[Ⅲ级/较重]",
"type": "雷电黄色",
"update_time": "2024-07-10 21:07:45"
}
],
"city": {
"cityId": 64,
"counname": "中国",
"ianatimezone": "Asia/Shanghai",
"name": "綦江区",
"pname": "重庆市",
"secondaryname": "重庆市",
"timezone": "8"
}
}
}| 状态码 | 描述 |
| 状态码 | 描述 |
| 101 | APPKEY为空或不存在 |
| 102 | APPKEY已过期 |
| 103 | APPKEY无请求此数据权限 |
| 104 | 请求超过次数限制 |
| 105 | IP被禁 |
| 106 | IP请求超过限制 |
| 107 | 接口维护中 |
| 108 | 接口已停用 |
| 计次套餐 | 权限 | 原价 | 优惠价 | 单价 |
| 免费套餐 | 100次 | 0.01 | / | ≈0.00010元/次 |
| Level1 | 50000次 | 99.00 | / | ≈0.00198元/次 |
| Level2 | 500000次 | 800.00 | / | ≈0.00160元/次 |
| Level3 | 1000000次 | 1200.00 | / | ≈0.00120元/次 |
| Level4 | 5000000次 | 5000.00 | / | ≈0.00100元/次 |
| Level5 | 10000000次 | 9000.00 | / | ≈0.00090元/次 |
| 更多优惠,请咨询 010-8639-9970 周一至周五(9:30-18:30) | ||||
| 包月套餐 | 权限 | 原价 | 优惠价 | 单价 |
| Level1-M | 3000次/天 | 150.00 | / | ≈0.00167元/次 |
| Level2-M | 5000次/天 | 260.00 | / | ≈0.00173元/次 |
| Level3-M | 10000次/天 | 499.00 | / | ≈0.00166元/次 |
| * 套餐使用时限为订购之日起30日。 | ||||
| 包年套餐 | 权限 | 原价 | 优惠价 | 单价 |
| Level1-Y | 100/QPS | 30000.00 | / | 不限次 |
| * 套餐使用时限为订购之日起1年。 | ||||
| 用户 | 购买时间 | 周期 | 套餐 |
| 172****9760 | 2025-11-26 14:19:14 | 一年 | **** |
| 153****3398 | 2025-06-10 23:39:51 | 一年 | **** |
| 152****4691 | 2025-05-09 22:42:21 | 一年 | **** |
| 133****5555 | 2025-02-11 15:38:02 | 一年 | **** |
| 138****6785 | 2024-06-28 11:03:41 | 一年 | **** |
| 186****7375 | 2024-06-14 12:16:11 | 一年 | **** |
| 130****5433 | 2024-04-24 21:08:39 | 一年 | **** |
| 176****3153 | 2023-12-22 10:35:26 | 一年 | **** |
| 137****9928 | 2023-10-27 23:27:28 | 一年 | **** |
| 156****6352 | 2022-11-21 09:05:09 | 一年 | **** |
