datacollect/ops/scripts.py
2019-08-13 14:32:36 +08:00

29 lines
887 B
Python

# -*- coding: utf-8 -*-
import pymongo
import pdb
import requests
def get_activity_ids():
# get data from mongodb
# mongodb://10.10.5.6:27017/garfield-production/system_dics
# {type: 'share_cfg', deleted: false}
myclient = pymongo.MongoClient("mongodb://10.10.5.6:27017/")
mydb = myclient["garfield-production"]
mycol = mydb["system_dics"]
myquery = {'type': 'share_cfg', 'deleted': False}
out_area = {'key': 1, 'value': 1, '_id': 0}
all = {}
for x in mycol.find(myquery, out_area):
all[x['key']]=x['value']
return all
def get_area_name():
button_name = {}
interface = "http://mp.kingsome.cn/api/open/promotion/get-area"
r = requests.get(interface)
if r.status_code == requests.codes.ok:
for line in r.json()['adAreaList']:
button_name[str(line['area_id'])] = line['name']
return button_name