From 7485a93730fd49118460c21985e08b889bb1813e Mon Sep 17 00:00:00 2001 From: pengtao Date: Wed, 23 Oct 2019 14:58:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A02001=20b=5FN=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_channel/produce_ss_csv.py | 31 +++++++++++++++++++++++++++++++ ops/mp_interface.py | 27 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 data_channel/produce_ss_csv.py create mode 100644 ops/mp_interface.py diff --git a/data_channel/produce_ss_csv.py b/data_channel/produce_ss_csv.py new file mode 100644 index 0000000..542f9f7 --- /dev/null +++ b/data_channel/produce_ss_csv.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +import pdb +from ops.mp_interface import MpInterface + + +class ProduceSSCsv: + def __init__(self): + # self.base_path = "/data/git/ops_interface/ops/csv" + self.base_path = "/tmp/" + self.gameid_list = [1004, 1001, 2001, 1011] + self.channelid = 6001 + + def write2csv(self, gameid, channelid, data): + filename = f"{gameid}_{channelid}__button_name.csv" + with open(filename, 'w') as f: + f.write("button_name,button_name_cn\n") + for line in data: + print(line) + + + def run(self): + mi = MpInterface() + + for gameid in self.gameid_list: + data = mi.get_co_list(gameid, self.channelid) + self.write2csv(gameid, self.channelid, data) + + +if __name__ == "__main__": + pp = ProduceSSCsv() + pp.run() diff --git a/ops/mp_interface.py b/ops/mp_interface.py new file mode 100644 index 0000000..6e72a90 --- /dev/null +++ b/ops/mp_interface.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +import requests + + +class MpInterface: + + def __init__(self): + self.base_url = "https://mp.kingsome.cn/api/open/cfg/all?" + + def get_data(self, url): + import requests + r = requests.get(url) + if r.status_code == requests.codes.ok: + return r.json().get('result') + else: + return None + + + def get_co_list(self, gameid, channelid): + key = "co-list" + url = f"{self.base_url}channelid={channelid}&gameid={gameid}&key={key}" + return self.get_data(url) + + def get_fromappid_cn(self, gameid, channelid): + key = "fromappid_cn" + url = f"{self.base_url}channelid={channelid}&gameid={gameid}&key={key}" + return self.get_data(url)