码迷,mamicode.com
首页 > 其他好文 > 详细

拉取数据经典版

时间:2018-04-11 18:07:12      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:import   pat   url   int   rtp   lin   tar   tpm   payment   

技术分享图片
 1 #! /usr/bin/env python
 2 # coding=utf-8
 3 import pymysql
 4 import json
 5 import urllib
 6 import time
 7 import urllib2
 8 import urllib
 9 import datetime
10 
11 url=http://engine.dashboard.sh2.ctripcorp.com:8080/jsonp/getgroupeddatapoints?reqdata={"version":1,"time-series-pattern":{"namespace":"ns-null","metrics-name":"payment.switch.rtpmonitor.metric.cost","tag-search-part":{}},"aggregator":{"accept-linear-interpolation":true,"function":"sum"},"downsampler":{"interval":"1d","function":"sum"},"max-datapoint-count":100,"start-time":"2018-04-10 00:00:00","end-time":"2018-04-11 00:00:00","rate":false,"group-by":["collectionid"],"maxGroupCount":100}
12 page=urllib.urlopen(url)
13 data=page.read()
14 json_data=json.loads(data)
15 local_data=json_data[time-series-group-list]
16 collectionid_total =[]
17 num_total =[]
18 for item in local_data:
19     collectionid = item["time-series-group"]["collectionid"]
20     num = item["data-points"]["total"]
21     collectionid_total.append(collectionid)
22     num_total.append(num)
23 print(zip(collectionid_total,num_total))
View Code

 

拉取数据经典版

标签:import   pat   url   int   rtp   lin   tar   tpm   payment   

原文地址:https://www.cnblogs.com/yspass/p/8797029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!