zoukankan      html  css  js  c++  java
  • 访问图灵机器人接口请求数据

    # Third-party Library
    import requests
    
    # POST请求参数
    args = {
        "reqType": 0,
        "perception": {
            "inputText": {
                "text": "北京"
            }
        },
        "userInfo": {
            "apiKey": "eaf3daedeb374564bfe9db10044bc20b",
            "userId": "6789"
        }
    }
    
    # 图灵机器人API接口
    url = "http://openapi.tuling123.com/openapi/api/v2"
    res = requests.post(url, json=args)
    print(res)
    # <Response [200]>
    print(res.json().get('results')[0].get('values').get('text'))
    """
    {
        'emotion': {
            'robotEmotion': {
                'a': 0,
                'd': 0,
                'emotionId': 0,
                'p': 0
            },
            'userEmotion': {
                'a': 0,
                'd': 0,
                'emotionId': 0,
                'p': 0
            }
        },
        'intent': {
            'actionName': '',
            'code': 10004,
            'intentName': ''
        },
        'results': [{
            'groupType': 0,
            'resultType': 'text',
            'values': {
                'text': '怎么老是一句话!'
            }
        }]
    }
    """
    # {'intent': {'code': 4003}, 'results': [{'groupType': 0, 'resultType': 'text', 'values': {'text': '请求次数超限制!'}}]}
    text = res.json().get("results")[0].get("values").get("text")
  • 相关阅读:
    伍佰《突然的自我》
    .NET常见ORM框架
    并发和压测工具
    底层源码调试工具
    c 冒泡排序
    c 指定范围的质数
    c 筛法列举质数
    c 牛顿法求方程近似解
    c 二分法求方程近似解
    css选择器 及其权重
  • 原文地址:https://www.cnblogs.com/apollo1616/p/10273938.html
Copyright © 2011-2022 走看看