添加2001 b_N上传方法
This commit is contained in:
parent
30413153bd
commit
f6170eed7b
@ -1,25 +1,45 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
|
from ops.ss_virtual_create import SS_Virtual_command
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Mp2shushu():
|
class Mp2shushu():
|
||||||
def __init__(self, channel, gameid):
|
def __init__(self, channel, gameid):
|
||||||
self.mp_url = f"https://mp.kingsome.cn/api/open/promotion/co-list?channelid={channel}&gameid={gameid}"
|
self.mp_url = f"https://mp.kingsome.cn/api/open/promotion/co-list?channelid={channel}&gameid={gameid}"
|
||||||
|
self.filename = "/data/git/ops_interface/ops/csv/2001_b_n.csv"
|
||||||
|
|
||||||
def get_ad_list(self):
|
def get_ad_list(self):
|
||||||
r = requests.get(self.mp_url)
|
r = requests.get(self.mp_url)
|
||||||
if r.status_code == requests.codes.ok:
|
if r.status_code == requests.codes.ok:
|
||||||
return r.json()
|
return self.split_data(r.json())
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def split_data(self, data):
|
def split_data(self, data):
|
||||||
try:
|
try:
|
||||||
result = data['result']
|
result = data['result']
|
||||||
|
begin = "b_n,b_n_china"
|
||||||
|
text = ""
|
||||||
|
for line in result:
|
||||||
|
text += ','.join(line) + '\n'
|
||||||
|
result_new = f"{begin}\n{text}"
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error(f"split {data} failed!", exc_info=True)
|
log.error(f"split {data} failed!", exc_info=True)
|
||||||
result = None
|
result_new = None
|
||||||
return result
|
return result_new
|
||||||
|
|
||||||
|
def write2csv(self, data):
|
||||||
|
with open(self.filename, 'w') as f:
|
||||||
|
f.write(data)
|
||||||
|
|
||||||
|
def upload2ss(self):
|
||||||
|
ss = SS_Virtual_command()
|
||||||
|
ss.upload_2001_b_n()
|
||||||
|
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
data = self.get_ad_list()
|
||||||
|
self.write2csv(data)
|
||||||
|
self.upload2ss()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user