12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- from app.api_data.cost_util import *
- from model.DateUtils import DateUtils
- from model.DataBaseUtils import MysqlUtils
- from concurrent.futures import ThreadPoolExecutor
- db = MysqlUtils()
- du = DateUtils()
- executor = ThreadPoolExecutor(max_workers=50)
- def get_accounts(filter=None):
- if filter:
- if filter=='MP':
- return db.quchen_text.getData("select account_id,access_token,name channel from advertiser_vx where (name !='' or name is not null)")
- else:
- return db.quchen_text.getData("select account_id,access_token,name channel from advertiser_qq where (name !='' or name is not null)")
- return db.quchen_text.getData("select account_id,access_token,name channel,'MP' flag from advertiser_vx where (name !='' or name is not null) union "
- "select account_id,access_token,name channel,'GDT' flag from advertiser_qq where (name !='' or name is not null)")
- """广告"""
- def ad():
- for account in get_accounts():
- executor.submit(get_ad_info, account[0], account[1],account[3])
- executor.shutdown()
-
- """广告日消耗"""
- def ad_cost_day():
- st = '2021-01-01'
- et = '2021-03-26'
- print(st,et)
- for account in get_accounts():
- # print(account)
- executor.submit(get_ad_cost_day, account[0], account[1],account[3],st,et)
- executor.shutdown()
- """图片"""
- def image():
- # 默认拉取前10天创建的图片
- for account in get_accounts():
- executor.submit(images_info_get, account[0], account[1])
- executor.shutdown()
- """创意"""
- def adcreative():
- for account in get_accounts():
- executor.submit(get_adcreatives, account[0], account[1],account[3])
- executor.shutdown()
- def run():
- image()
- ad()
- adcreative()
- ad_cost_day()
- if __name__ == '__main__':
- # MP
- # account_id = 18516323
- # access_token = '262deda76aec00c2e144e83bd3c0b2a2'
- #
- # account_id2= 14709511
- # access_token2 = 'e87f7b6f860eaeef086ddcc9c3614678'
- run()
|