You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.5 KiB

5 years ago
from urllib.request import urlopen, Request
import ssl
import json
host = 'https://jisuwnl.market.alicloudapi.com'
# path = '/calendar/holiday'
path = '/calendar/query'
method = 'GET'
appcode = '32394ce559ff4551936f79a7ea8237f0'
querys = 'date=2019-08-28'
bodys = {}
# url = host + path
url = host + path + '?' + querys
request = Request(url)
request.add_header('Authorization', 'APPCODE ' + appcode)
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
response = urlopen(request, context=ctx)
content = response.read()
content_dict = json.loads(content.decode('utf-8'))
# print(content_dict['result']['2019-10-01']['content'])
print(content_dict['result'])
"""
输出格式
{'status': 0, 'msg': 'ok',
'result': {'2018-12-30': {'name': '元旦', 'content': '12月30日至1月1日放假共三天与周末连休。'},
'2019-02-04': {'name': '春节', 'content': '2月04日至2月10日放假调休共7天。2月2日周六、2月3日周日上班。'},
'2019-04-05': {'name': '清明节', 'content': '4月5日至7日放假调休共3天与周末连休。'},
'2019-05-01': {'name': '劳动节', 'content': '无调休共1天。'},
'2019-06-07': {'name': '端午节', 'content': '6月07日至09日放假共3天与周末连休。'},
'2019-09-13': {'name': '中秋节', 'content': '9月13日至15日放假共3天与周末连休。'},
'2019-10-01': {'name': '国庆节', 'content': '10月1日至7日放假调休共7天。9月29日周日、10月12日周六上班。'}}}
"""