首页 黄历查询 黄历查询示例代码 黄历查询[Python]

黄历查询示例代码[Python]

作者:liuxiaojie 阅读数:1747 上传时间:2016-03-10

黄历查询

#!/usr/bin/python
# encoding:utf-8

import urllib2, json, urllib



# 1、黄历查询


data = {}
data["appkey"] = "your_appkey_here"
data["year"] = 2015
data["month"] = 10
data["day"] = 27

url_values = urllib.urlencode(data)
url = "https://api.jisuapi.com/huangli/date" + "?" + url_values
request = urllib2.Request(url)
result = urllib2.urlopen(request)
jsonarr = json.loads(result.read())

if jsonarr["status"] != u"0":
    print jsonarr["msg"]
    exit()
result = jsonarr["result"]
print result["year"],result["month"],result["day"],result["yangli"],result["nongli"],result["star"],result["taishen"],result["wuxing"],result["chong"],result["sha"],result["shengxiao"],result["jiri"],result["zhiri"],result["xiongshen"],result["jishenyiqu"],result["caishen"],result["xishen"],result["fushen"]," ".join(result["suici"])," ".join(result["yi"])," ".join(result["ji"]),result["eweek"],result["emonth"],result["week"]