您的位置:首页 > 运维架构 > Shell

shell 智能机器人

2017-02-16 17:35 288 查看
#!/bin/bash
#read -p "请输入您想和小young说的话:" input
#curl -G -d "key=abda91b36e4943daa38ed8af41eae833&info=$input" http://www.tuling123.com/openapi/api |cut -d ":" -f3|cut -d '"' -f2
# {"code":100000,"text":"嘿嘿,你脸红了啊"}  cat 1 |cut -d ":" -f3|cut -d '"' -f2
while [[ true ]]; do
read -p "请输入您想和小young说的话:" input
curl -G -d "key=这里输入您申请的KEY&info=$input" -s http://www.tuling123.com/openapi/api |cut -d ":" -f3|cut -d '"' -f2
done


附上截图;



那是之前的版本 现在附上改进后的版本,

#!/bin/bash
#read -p "请输入您想和小young说的话:" input
#curl -G -d "key=abda91b36e4943daa38ed8af41eae833&info=$input" http://www.tuling123.com/openapi/api |cut -d ":" -f3|cut -d '"' -f2
# {"code":100000,"text":"嘿嘿,你脸红了啊"}  cat 1 |cut -d ":" -f3|cut -d '"' -f2
#jq 是一个截取json的命令   wget http://stedolan.github.io/jq/download/linux64/jq export LANG=zh_CN.UTF-8
while [[ true ]]; do
read -p "请输入您想和小young说的话:" i
curl -H "Content-Type: application/json" -X POST -d '{"key":"abda91b36e4943daa38ed8af41eae833","info":"'"${i}"'"}' -s http://www.tuling123.com/openapi/api |jq '.'|grep -v -E "{|}"
done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: