图灵小机器人自动回复

图灵小机器人发送微信消息

# @Time : 2019/4/3 15:16
# @Author  :小二
# @File :1.py
import urllib.request
import urllib.parse
import json
import requests


url = "http://openapi.tuling123.com/openapi/api/v2"
headers = {'content-type': 'application/json'}
post_data = {
    "reqType":0,
    "perception":{
        "inputText":{
            "text":"附近酒店"
        },
        "inputImage":{
            "url":"https://cn.bing.com/images/"
        },
        "selfInfo":{
            "location":{
                "city":"",
                "province":"",
                "street":""
            }
        }


    },
    "userInfo":{
        "apiKey":"",
        "userId":""
    }
}

# response = json.loads(urllib.request.urlopen(urllib.request.Request(url=url,data=urllib.parse.urlencode(post_data).encode("utf-8"))).read().decode("utf-8"))
response = requests.post(url,headers=headers,data=json.dumps(post_data)).json()
print(response)
response = response["results"][0]["values"]["text"]
print(response)

你可能感兴趣的:(爬虫)