demo_OceanEngineAd.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. # -*- codeing = utf-8 -*-
  2. # @Time : 2023/3/22 13:36
  3. # @Author : Clown
  4. # @File : demo_baiduAd.py
  5. # @Software : PyCharm
  6. import requests
  7. import json
  8. import schedule
  9. import threading
  10. import time
  11. import pymysql
  12. from datetime import datetime, timedelta
  13. from dateutil.parser import parse
  14. import traceback
  15. from all_key_table import update_key_value_pair_7qiaoPlus
  16. from demo_feiyu_ad_tk_refresh import getAllFeiYuUsersList
  17. def linkTomySql(host, passwd, db_name, port):
  18. '''连接至数据库返回【db】,v2新增local_infile=1 打开文件导入权限'''
  19. try:
  20. # 本地连接为:localhost 服务器连接为:124.222.188.59
  21. db = pymysql.connect (
  22. host=host, user="root",
  23. passwd=passwd,
  24. db=db_name,
  25. port=port,
  26. charset='utf8mb4',
  27. local_infile=1)
  28. print ('\nconnect to mysql server 成功')
  29. print ('---------------------------------------')
  30. except:
  31. print ("\ncould not connect to mysql server")
  32. db = "连接失败"
  33. return db
  34. def read_key_value_pair(db, brand_name, wm_plate, owner):
  35. '''按条件读取,数据库中all_key_table表里的key_value_pair字段中的值,以键值对的形式输出
  36. db:数据库,
  37. brand_name:品牌名,
  38. wm_plate:外卖平台MEITUAN或ELEME,
  39. owner:账号权限all或one
  40. '''
  41. cursor = db.cursor ()
  42. sql = f'SELECT key_value_pair FROM all_key_table WHERE brand_name = "{brand_name}" AND wm_plate = "{wm_plate}" AND owner = "{owner}";'
  43. cursor.execute (sql)
  44. pair = json.loads (cursor.fetchall ()[0][0])
  45. return pair
  46. def orderTo7qiao(db, lastCatchTime_ago_s, solutionCntAll, solutionJsonData):
  47. solutionjsondata = {'data': solutionJsonData}
  48. key_json = read_key_value_pair (db, '道一云', '7qiaoPlus', 'all')
  49. applicationId = '63631ee57005c0103426fdc7'
  50. processId = '642128bd80236836229b3b1d'
  51. Token = key_json['data']
  52. headers_api = {
  53. 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36',
  54. "Content-type": "application/json",
  55. "X-Auth0-Token": Token}
  56. url = f'https://qiqiao.do1.com.cn/plus/cgi-bin/open/applications/{applicationId}/workflow/process_definitions/{processId}/start'
  57. params_json = {
  58. "nextNodesAndHandlers": [{"activityDefinitionId": "obj_02"}],
  59. "variables": {"任务触发时间": lastCatchTime_ago_s, 'solutioncntall': solutionCntAll,
  60. 'solutionjsondata': json.dumps (solutionjsondata, ensure_ascii=False)},
  61. "loginUserId": "92874ed35ecb45f51a58adcf18e99b5e"}
  62. try:
  63. resp = requests.post (url, headers=headers_api, json=params_json)
  64. msg = resp.json ()['msg']
  65. print (resp.text)
  66. if msg == '执行成功':
  67. operation_results = '无异常'
  68. else:
  69. operation_results = f'[orderTo7qiao]-返回结果为{msg}'
  70. except Exception as e:
  71. operation_results = f'[orderTo7qiao]-道一云端无法连接{e}'
  72. return operation_results
  73. def sendMsgToRot(url, msg_txt):
  74. params_json = {
  75. "msgtype": "markdown",
  76. "markdown": {
  77. "content": msg_txt,
  78. "mentioned_list": ["@all"]
  79. }}
  80. resp = requests.post (url, json=params_json).text
  81. print (resp)
  82. # 查询投放信息
  83. def feiyuAD(advertiser_ids, accessToken, lastCatchTime_ago_s, lastCatchTime_now_s):
  84. open_api_url_prefix = "https://ad.oceanengine.com/open_api/"
  85. uri = "2/tools/clue/get/"
  86. url = open_api_url_prefix + uri
  87. user_payload = {'advertiser_ids': advertiser_ids,
  88. 'start_time': lastCatchTime_ago_s,
  89. 'end_time': lastCatchTime_now_s,
  90. 'page_size': 100,
  91. 'page': 1}
  92. http_headers = {
  93. "Access-Token": accessToken
  94. }
  95. try:
  96. response = requests.get (url, json=user_payload, headers=http_headers)
  97. except:
  98. response = 'Error'
  99. return response
  100. # 查询计时器时间,输出起始时间
  101. def selectfeiyu_ad_time_meter(db):
  102. cursor = db.cursor ()
  103. sql = f'SELECT * FROM feiyu_ad_time_meter WHERE id = 1;'
  104. cursor.execute (sql)
  105. lastCatchTime_ago = cursor.fetchall ()[0][0]
  106. lastCatchTime_ago_s = (lastCatchTime_ago + timedelta (seconds=1)).strftime ('%Y-%m-%d %H:%M:%S')
  107. # 更新间隔
  108. lastCatchTime_now_s = (lastCatchTime_ago + timedelta (minutes=5)).strftime ('%Y-%m-%d %H:%M:%S')
  109. cursor.close ()
  110. return lastCatchTime_ago_s, lastCatchTime_now_s
  111. # 更新计时器时间
  112. def updatefeiyu_ad_time_meter(db, lastCatchTime_now_s):
  113. cursor = db.cursor ()
  114. sql = f'UPDATE feiyu_ad_time_meter SET lastCatchTime = "{lastCatchTime_now_s}" WHERE id = 1;'
  115. cursor.execute (sql)
  116. db.commit ()
  117. cursor.close ()
  118. # 新增记录至抓取记录表
  119. def insertfeiyu_ad_solution_catch(db, insert_valuse):
  120. cursor = db.cursor ()
  121. sql = f'INSERT INTO feiyu_ad_solution_catch VALUES (%s,%s,%s,%s,%s,%s,%s,%s);'
  122. cursor.execute (sql, insert_valuse)
  123. db.commit ()
  124. cursor.close ()
  125. # 新增记录至抓取明细记录表
  126. def insertfeiyu_ad_solution_info(db, insert_valuse):
  127. cursor = db.cursor ()
  128. sql = f'REPLACE INTO feiyu_ad_solution_info VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);'
  129. cursor.execute (sql, insert_valuse)
  130. db.commit ()
  131. cursor.close ()
  132. # 检查数据库中是否有数据
  133. def checkfeiyu_ad_solution_info_in_table(db,clueId):
  134. cursor = db.cursor ()
  135. sql = f'SELECT * FROM feiyu_ad_solution_info WHERE clueId = "{clueId}";'
  136. cursor.execute (sql)
  137. cnt = cursor.fetchall ()
  138. if len(cnt) == 0:
  139. result = True
  140. else:
  141. result = False
  142. return result
  143. # 解析分配数据至分配队列
  144. def dumpFeiYuJosn(db, userName, brandName, routeName, response_json, mode):
  145. '''
  146. userName 账号
  147. brandName 品牌
  148. routeName 投流渠道
  149. response_json 请求返回的json文件
  150. '''
  151. solutionJsonDatas = []
  152. datas = response_json['data']['list']
  153. for data in datas:
  154. clueId = data['clue_id']
  155. commitTime = data['create_time_detail']
  156. try:
  157. solutionNum = {'0': '表单提交',
  158. '1': '在线咨询',
  159. '2': '智能电话',
  160. '3': '网页回呼',
  161. '4': '卡券',
  162. '5': '抽奖'}
  163. solutionType = solutionNum[str (data['clue_type'])]
  164. except:
  165. solutionType = '其他'
  166. try:
  167. module_name = data['module_name']
  168. except:
  169. module_name = '其他'
  170. solutionType = f'{solutionType}-{module_name}'
  171. try:
  172. clueName = data['name']
  173. except:
  174. clueName = '未知'
  175. cluePhoneNumber = data['telephone']
  176. try:
  177. flowChannelNum = {'0': '外部流量',
  178. '1': '正常投放',
  179. '2': '外部导入',
  180. '3': '异常提交',
  181. '4': '广告预览',
  182. '5': '抖音私信',
  183. '6': '鲁班线索'}
  184. flowChannelName = flowChannelNum[str (data['clue_source'])]
  185. except:
  186. flowChannelName = '其他'
  187. try:
  188. app_name = data['app_name']
  189. except:
  190. app_name = '未知app'
  191. flowChannelName = f'{flowChannelName}-{app_name}'
  192. try:
  193. area = data['location']
  194. except:
  195. area = '未知区域'
  196. # try:
  197. # searchWord = solution['searchWord']
  198. # except:
  199. searchWord = ''
  200. # try:
  201. # keyword = solution['keyword']
  202. # except:
  203. keyword = ''
  204. solutionInfo = json.dumps (data, ensure_ascii=False)
  205. try:
  206. userName = data['advertiser_name']
  207. except:
  208. userName = '未知'
  209. insert_valuse = (
  210. clueId, commitTime, solutionType, clueName, cluePhoneNumber, flowChannelName, area, searchWord, keyword,
  211. solutionInfo, userName, brandName, routeName)
  212. if mode == 'check':
  213. check_result = checkfeiyu_ad_solution_info_in_table (db, clueId)
  214. if check_result:
  215. insertfeiyu_ad_solution_info (db, insert_valuse)
  216. solutionJsonData = {'clueId': clueId,
  217. 'commitTime': commitTime,
  218. 'solutionType': solutionType,
  219. 'clueName': clueName,
  220. 'cluePhoneNumber': cluePhoneNumber,
  221. 'flowChannelName': flowChannelName,
  222. 'area': area,
  223. 'searchWord': searchWord,
  224. 'keyword': keyword,
  225. 'userName': userName,
  226. 'brandName': brandName,
  227. 'routeName': routeName}
  228. solutionJsonDatas.append (solutionJsonData)
  229. else:
  230. insertfeiyu_ad_solution_info (db, insert_valuse)
  231. solutionJsonData = {'clueId': clueId,
  232. 'commitTime': commitTime,
  233. 'solutionType': solutionType,
  234. 'clueName': clueName,
  235. 'cluePhoneNumber': cluePhoneNumber,
  236. 'flowChannelName': flowChannelName,
  237. 'area': area,
  238. 'searchWord': searchWord,
  239. 'keyword': keyword,
  240. 'userName': userName,
  241. 'brandName': brandName,
  242. 'routeName': routeName}
  243. solutionJsonDatas.append (solutionJsonData)
  244. return solutionJsonDatas
  245. # 执行数据抓取
  246. def runFeiYuAD(db, userName, accessToken, brandName, routeName, lastCatchTime_ago_s, lastCatchTime_now_s,
  247. advertiser_ids, mode):
  248. operation_results = '无异常'
  249. solutionJsonDataList = []
  250. solutionType = 'all'
  251. response = feiyuAD (advertiser_ids, accessToken, lastCatchTime_ago_s, lastCatchTime_now_s)
  252. if response == 'Error':
  253. response_data = 'Error'
  254. operation_results = '[runBaiduAD]-[baiduAD]请求失败'
  255. else:
  256. response_data = response.text
  257. response_json = response.json ()
  258. try:
  259. desc = response_json['message']
  260. solutionCnt = response_json['data']['page_info']['total_number']
  261. solutionJsonDatas = dumpFeiYuJosn (db, userName, brandName, routeName, response_json, mode)
  262. solutionJsonDataList = solutionJsonDataList + solutionJsonDatas
  263. except:
  264. operation_results = '[runBaiduAD]-[response_json]无法解析'
  265. desc = 'fail'
  266. solutionCnt = 0
  267. insert_valuse = (
  268. lastCatchTime_now_s, response_data, solutionCnt, desc, solutionType, userName, brandName, routeName)
  269. insertfeiyu_ad_solution_catch (db, insert_valuse)
  270. print (response_data)
  271. return operation_results, solutionJsonDataList
  272. # 定时更新7巧密钥,每6小时更新一次
  273. def update7qiaoToken(db):
  274. now = datetime.now ()
  275. mm = now.strftime ("%M")
  276. hh = now.strftime ("%H")
  277. if int (hh) % 6 == 0 and int (mm) <= 1:
  278. update_key_value_pair_7qiaoPlus (db, '道一云', '7qiaoPlus', 'all', '')
  279. # 多账号计时抓取投流数据
  280. def runADsolution(db):
  281. # 基础参数
  282. operation_results = '无异常'
  283. e = 'no'
  284. mode = 'run'
  285. # host = 'localhost'
  286. # passwd = '111???clown'
  287. # db_name = 'hexingxing'
  288. # port = 3306
  289. feiyu_kisses = getAllFeiYuUsersList (db)
  290. try:
  291. # db = linkTomySql (host, passwd, db_name, port)
  292. lastCatchTime_ago_s, lastCatchTime_now_s = selectfeiyu_ad_time_meter (db)
  293. for feiyu_kis in feiyu_kisses:
  294. userName = feiyu_kis['userName']
  295. accessToken = feiyu_kis['accessToken']
  296. brandName = feiyu_kis['brandName']
  297. advertiser_ids = feiyu_kis['advertiser_ids']
  298. routeName = feiyu_kis['routeName']
  299. operation_results, solutionJsonDataList = runFeiYuAD (db, userName, accessToken, brandName, routeName,
  300. lastCatchTime_ago_s, lastCatchTime_now_s,
  301. advertiser_ids, mode)
  302. solutionCntAll = len (solutionJsonDataList)
  303. # update7qiaoToken (db)
  304. if 1 == 1:
  305. if solutionCntAll > 0:
  306. if len (str (solutionJsonDataList)) >= 5000:
  307. for solutionJsonDataList_0 in solutionJsonDataList:
  308. operation_results = orderTo7qiao (db, lastCatchTime_now_s, 1, solutionJsonDataList_0)
  309. time.sleep (0.5)
  310. else:
  311. operation_results = orderTo7qiao (db, lastCatchTime_now_s, solutionCntAll, solutionJsonDataList)
  312. # 发送报错信息
  313. if operation_results != '无异常':
  314. url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cf7139e1-e623-41ca-8541-5dc6e26d43b0'
  315. msg_txt = f'<font color=\"warning\">【飞鱼投流数据同步】服务端出现异常,请管理员尽快处理!</font>\n>Exception->{e}\nDetail->{operation_results}'
  316. sendMsgToRot (url, msg_txt)
  317. else:
  318. ...
  319. updatefeiyu_ad_time_meter (db, lastCatchTime_now_s)
  320. # db.close ()
  321. except Exception as e:
  322. operation_results = traceback.format_exc ()
  323. e = 'no'
  324. # 发送报错信息
  325. if operation_results != '无异常':
  326. url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cf7139e1-e623-41ca-8541-5dc6e26d43b0'
  327. msg_txt = f'<font color=\"warning\">【飞鱼投流数据同步】服务端出现异常,请管理员尽快处理!</font>\n>Exception->{e}\nDetail->{operation_results}'
  328. sendMsgToRot (url, msg_txt)
  329. else:
  330. ...
  331. # 检查未成功获取的数据
  332. def runADsolutionCheck(db,time_slot):
  333. # 基础参数
  334. operation_results = '无异常'
  335. e = 'no'
  336. mode = 'check'
  337. # host = 'localhost'
  338. # passwd = '111???clown'
  339. # db_name = 'hexingxing'
  340. # port = 3306
  341. feiyu_kisses = getAllFeiYuUsersList (db)
  342. try:
  343. # db = linkTomySql (host, passwd, db_name, port)
  344. now = datetime.now ().strftime ('%Y%m%d')
  345. lastCatchTime_ago_s = (parse (now) + timedelta (hours=time_slot[0])).strftime ('%Y-%m-%d %H:%M:%S')
  346. lastCatchTime_now_s = (parse (now) + timedelta (hours=time_slot[1])).strftime ('%Y-%m-%d %H:%M:%S')
  347. # lastCatchTime_ago_s, lastCatchTime_now_s = selectfeiyu_ad_time_meter (db)
  348. for feiyu_kis in feiyu_kisses:
  349. userName = feiyu_kis['userName']
  350. accessToken = feiyu_kis['accessToken']
  351. brandName = feiyu_kis['brandName']
  352. advertiser_ids = feiyu_kis['advertiser_ids']
  353. routeName = feiyu_kis['routeName']
  354. operation_results, solutionJsonDataList = runFeiYuAD (db, userName, accessToken, brandName, routeName,
  355. lastCatchTime_ago_s, lastCatchTime_now_s,
  356. advertiser_ids, mode)
  357. solutionCntAll = len (solutionJsonDataList)
  358. # update7qiaoToken (db)
  359. if 1 == 1:
  360. if solutionCntAll > 0:
  361. if len (str (solutionJsonDataList)) >= 5000:
  362. for solutionJsonDataList_0 in solutionJsonDataList:
  363. operation_results = orderTo7qiao (db, lastCatchTime_now_s, 1, solutionJsonDataList_0)
  364. time.sleep (0.5)
  365. else:
  366. operation_results = orderTo7qiao (db, lastCatchTime_now_s, solutionCntAll, solutionJsonDataList)
  367. # 发送报错信息
  368. if operation_results != '无异常':
  369. url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cf7139e1-e623-41ca-8541-5dc6e26d43b0'
  370. msg_txt = f'<font color=\"warning\">【飞鱼投流数据同步】服务端出现异常,请管理员尽快处理!</font>\n>Exception->{e}\nDetail->{operation_results}'
  371. sendMsgToRot (url, msg_txt)
  372. else:
  373. ...
  374. # updatefeiyu_ad_time_meter (db, lastCatchTime_now_s)
  375. # db.close ()
  376. except Exception as e:
  377. operation_results = traceback.format_exc ()
  378. e = 'no'
  379. # 发送报错信息
  380. if operation_results != '无异常':
  381. url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cf7139e1-e623-41ca-8541-5dc6e26d43b0'
  382. msg_txt = f'<font color=\"warning\">【飞鱼投流数据同步】服务端出现异常,请管理员尽快处理!</font>\n>Exception->{e}\nDetail->{operation_results}'
  383. sendMsgToRot (url, msg_txt)
  384. else:
  385. ...
  386. def run(db):
  387. # 初始化时间周期
  388. # 更新间隔
  389. minute = 5
  390. f_now = datetime.now ()
  391. f_mm = f_now.strftime ("%M")
  392. f_ss = f_now.strftime ("%S")
  393. f_c = int (f_mm) % minute
  394. wait_s = (minute - f_c - 1) * 60 + 59 - int (f_ss)
  395. time.sleep (wait_s)
  396. # 执行循环
  397. while True:
  398. now = datetime.now ()
  399. mm = now.strftime ("%M")
  400. ss = now.strftime ("%S")
  401. c = int (mm) % minute
  402. if c == 0 and ss == '01':
  403. s = time.time ()
  404. # print(now)
  405. runADsolution (db)
  406. time.sleep (minute * 60 - 0.5 - (time.time () - s))
  407. # 飞鱼推送
  408. def get_access_token():
  409. open_api_url_prefix = "https://open.oceanengine.com/open_api/"
  410. uri = "oauth2/app_access_token/"
  411. url = open_api_url_prefix + uri
  412. data = {
  413. "app_id": 1761788970859667,
  414. "secret": "dd148df1cb5feb6d0f25639ad7176bf387ef53f7"
  415. }
  416. rsp = requests.post (url, json=data)
  417. access_token = rsp.json ()['data']['access_token']
  418. return access_token
  419. def get_clue_list(token):
  420. open_api_url_prefix = "https://ad.oceanengine.com/open_api/"
  421. uri = "2/tools/clue/get/"
  422. url = open_api_url_prefix + uri
  423. headers = {"Access-Token": token}
  424. data = {
  425. 'advertiser_ids': ['2828422484857512'],
  426. 'start_time': '2022-04-01',
  427. 'end_time': '2022-04-11'
  428. }
  429. rsp = requests.get (url, json=data, headers=headers)
  430. rsp_data = rsp.json ()
  431. print (json.dumps (rsp_data, ensure_ascii=False))
  432. return rsp_data
  433. if __name__ == '__main__':
  434. if 1==1:
  435. advertiser_ids = ['1762396620978184','1762396621515784','1762396622070791']
  436. accessToken = 'c06ac76994e55d4951223e38d174b2591efb7065'
  437. open_api_url_prefix = "https://ad.oceanengine.com/open_api/"
  438. uri = "2/advertiser/info/"
  439. url = open_api_url_prefix + uri
  440. params = {
  441. "advertiser_ids": advertiser_ids,
  442. "fields": ["id", "name", "note"]
  443. }
  444. headers = {"Access-Token": accessToken}
  445. rsp = requests.get (url, json=params, headers=headers)
  446. rsp_data = rsp.json()
  447. print(json.dumps(rsp_data,ensure_ascii=False))
  448. if 1 == 0:
  449. host = '124.222.188.59'
  450. passwd = '111...Clown'
  451. db_name = 'zuzu_data'
  452. port = 63306
  453. db = linkTomySql (host, passwd, db_name, port)
  454. # 更新至当前,用于重启服务时,自动更新数据
  455. lastCatchTime_ago_s, lastCatchTime_now_s = selectfeiyu_ad_time_meter (db)
  456. while parse (lastCatchTime_now_s) <= (datetime.now () + timedelta (minutes=-10)):
  457. runADsolution (db)
  458. time.sleep (2)
  459. lastCatchTime_ago_s, lastCatchTime_now_s = selectfeiyu_ad_time_meter (db)
  460. db.close ()
  461. # 正式运行
  462. print ('正式运行')
  463. db = linkTomySql (host, passwd, db_name, port)
  464. run (db)
  465. db.close ()
  466. if 1 == 0:
  467. url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cf7139e1-e623-41ca-8541-5dc6e26d43b0'
  468. ff = '''Traceback (most recent call last):
  469. File "/home/python_flies/Num_Of_OrdersPerCapita_InRecentD30D90_E.py", line 293, in <module>
  470. csv_name_storage,csv_name_application = Num_Of_OrdersPerCapita_InRecentD30D90_E(file_path, brand_name, elm_pair, shops_info_df)
  471. File "/home/python_flies/Num_Of_OrdersPerCapita_InRecentD30D90_E.py", line 253, in Num_Of_OrdersPerCapita_InRecentD30D90_E
  472. e = 0/0 #v2优化
  473. ZeroDivisionError: division by zero
  474. During handling of the above exception, another exception occurred:
  475. Traceback (most recent call last):
  476. File "/home/python_flies/Num_Of_OrdersPerCapita_InRecentD30D90_E.py", line 298, in <module>
  477. csv_name_storage, csv_name_application = Num_Of_OrdersPerCapita_InRecentD30D90_E(file_path, brand_name, elm_pair, shops_info_df)
  478. File "/home/python_flies/Num_Of_OrdersPerCapita_InRecentD30D90_E.py", line 253, in Num_Of_OrdersPerCapita_InRecentD30D90_E
  479. e = 0/0 #v2优化
  480. ZeroDivisionError: division by zero
  481. '''
  482. msg_txt = f'<font color=\"warning\">【百度投流数据同步】服务端出现异常,请管理员尽快处理!</font>\n>Exception->测试\nDetail->{ff}'
  483. sendMsgToRot (url, msg_txt)
  484. if 1==0:
  485. host = '124.222.188.59'
  486. passwd = '111...Clown'
  487. db_name = 'zuzu_data'
  488. port = 63306
  489. db = linkTomySql (host, passwd, db_name, port)
  490. # advertiser_ids = [1758512677972046, 1758589190448142, 1758589191073800, 1758589191664648, 1758589192210568, 1758589192767501]
  491. # accessToken = 'f14ee576aad9503b529e5a0123126cdd12169577'
  492. # lastCatchTime_ago_s = '2023-04-01 12:04:43'
  493. # lastCatchTime_now_s = '2023-04-19 12:04:43'
  494. # print(feiyuAD(advertiser_ids, accessToken, lastCatchTime_ago_s, lastCatchTime_now_s).text)
  495. print(getAllFeiYuUsersList (db))
  496. db.close ()
  497. if 1==0:
  498. now = datetime.now ().strftime('%Y%m%d')
  499. s_time = (parse(now)+timedelta(hours=0)).strftime('%Y-%m-%d %H:%M:%S')
  500. e_time = (parse(now)+timedelta(hours=2)).strftime('%Y-%m-%d %H:%M:%S')
  501. print(s_time,e_time)