Quellcode durchsuchen

MOD:添加消耗广告数据埋点

cxyu vor 3 Jahren
Ursprung
Commit
49ecb3ced1
1 geänderte Dateien mit 3 neuen und 9 gelöschten Zeilen
  1. 3 9
      app/api_data/tx_ad_cost/cost_util.py

+ 3 - 9
app/api_data/tx_ad_cost/cost_util.py

@@ -1,9 +1,6 @@
-
 import json
-import random
 import requests
 import time
-from datetime import datetime
 import pymysql
 import logging
 from concurrent.futures import ThreadPoolExecutor
@@ -84,7 +81,7 @@ def get_adcreatives(account_id,access_token,flag,adc_ids,dt):  # 获取创意
     url = 'https://api.e.qq.com/v1.1/adcreatives/get'
     li =[]
     page = 1
-
+    logging.info(f"{account_id}开始获取创意")
     while True:
 
         parameters = {
@@ -112,7 +109,7 @@ def get_adcreatives(account_id,access_token,flag,adc_ids,dt):  # 获取创意
 
 
         while True:
-            h = requests.get(url, params=parameters)
+            h = requests.get(url, params=parameters,timeout=10)
             # logging.info(h.json())
 
             if h.status_code == 200:
@@ -182,10 +179,6 @@ def get_adcreatives(account_id,access_token,flag,adc_ids,dt):  # 获取创意
                         )
                     )
 
-
-
-
-
             total_page = r['data']['page_info']['total_page']
             if total_page > page:
                 page += 1
@@ -193,6 +186,7 @@ def get_adcreatives(account_id,access_token,flag,adc_ids,dt):  # 获取创意
                 break
         else:
             break
+    logging.info(f"{account_id}获取创意,结束")
     if len(li)>0:
         logging.info(f"{account_id}有创意:"+str(len(li)))
         sql='replace into adcreative_info values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) '