很多语言都可以做到,php/nodejs/java/python.....
如果你这些都不会,会shell 也可以做到,写入mysql没问题,oracle我不太知道行不行
我给你一个大概的shell例子,你应该就明白了
从json接口获得的数据是这些:
{"data": [
{
"opentimestamp": 1520237469,
"opentime": "2018-03-05 16:11:09",
"opencode": "*,6,4,7,7",
"expect": "20180305061"
},
{
"opentimestamp": 1520236868,
"opentime": "2018-03-05 16:01:08",
"opencode": "*,4,8,2,9",
"expect": "20180305060"
},
{
"opentimestamp": 1520236269,
"opentime": "2018-03-05 15:51:09",
"opencode": "*,7,8,4,9",
"expect": "20180305059"
},
{
"opentimestamp": 1520235666,
"opentime": "2018-03-05 15:41:06",
"opencode": "*,3,9,9,9",
"expect": "20180305058"
},
{
"opentimestamp": 1520235069,
"opentime": "2018-03-05 15:31:09",
"opencode": "*,1,0,4,9",
"expect": "20180305057"
}
],
"info": "演示接口隐藏第1位数据,实时接口请访问www.opencai.net查询、购买或续费",
"code": "cqssc",
"rows": 5
}
shell 脚本如下,如果你想获得这个json的data value
#!/bin/shresult=$(curl -A "Mozilla/4.0 (compatible MSIE 6.0 Windows NT 5.0)" "http://t.apiplus.net/newly.do?code=cqssc&format=json")
echo $result|jq -r ".data"
如果你想获得data 的第一个json数据
#!/bin/shresult=$(curl -A "Mozilla/4.0 (compatible MSIE 6.0 Windows NT 5.0)" "http://t.apiplus.net/newly.do?code=cqssc&format=json")
echo $result|jq -r ".data[0]"
如果你想获得data的第一个json数据opentimestamp的value
#!/bin/shresult=$(curl -A "Mozilla/4.0 (compatible MSIE 6.0 Windows NT 5.0)" "http://t.apiplus.net/newly.do?code=cqssc&format=json")
echo $result|jq -r ".data[0]"|jq -r .opentimestamp
如果你想写入到mysql可以参考下面的语句:
mysql -uroot -proot test -e "insert into ttest (key,value) values ('testkey','testvalue')"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)