聚合数据api接入-Python版本

#!/usr/bin/python
# -*- coding: utf-8 -*-
import json, urllib
from urllib.parse import urlencode
import requests

def main():
    # 配置您申请的APPKey
    appkey = "624ff8635d4b228de27cd8591ebbf854"
    mydate = "2017-2-16"
    # 1.获取当天的详细信息
    request1(appkey, mydate)

# 获取当天的详细信息
def request1(appkey,mydate):
    url = "http://v.juhe.cn/calendar/day"
    payload = {
        "key": appkey,  # 您申请的appKey
        "date":mydate,  # 指定日期,格式为YYYY-MM-DD,如月份和日期小于10,则取个位,如:2012-1-1
    }
    f = requests.get(url,params=payload)
    print(f.url)
    print(f.text)

if __name__ == '__main__':
    main()

你可能感兴趣的:(python)