|  | @@ -55,7 +55,7 @@ def get_campaign(account_id, access_token, flag,campaign_ids,dt):
 | 
	
		
			
				|  |  |                  time.sleep(61)
 | 
	
		
			
				|  |  |              else:
 | 
	
		
			
				|  |  |                  break
 | 
	
		
			
				|  |  | -        # print(r)
 | 
	
		
			
				|  |  | +        # logging.info(r)
 | 
	
		
			
				|  |  |          total_page = r['data']['page_info']['total_page']
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if page > total_page:
 | 
	
	
		
			
				|  | @@ -70,10 +70,10 @@ def get_campaign(account_id, access_token, flag,campaign_ids,dt):
 | 
	
		
			
				|  |  |                             DateUtils.stamp_to_str(i['created_time']),
 | 
	
		
			
				|  |  |                             DateUtils.stamp_to_str(i['last_modified_time']),i.get('speed_mode'),i.get('is_deleted'),
 | 
	
		
			
				|  |  |                             account_id, flag, dt))
 | 
	
		
			
				|  |  | -    # print(li)
 | 
	
		
			
				|  |  | +    # logging.info(li)
 | 
	
		
			
				|  |  |      """mp 没有 speed_mode,is_deleted,budget_reach_date"""
 | 
	
		
			
				|  |  |      if li.__len__() > 0:
 | 
	
		
			
				|  |  | -        print(f"{account_id}有计划:", li.__len__())
 | 
	
		
			
				|  |  | +        logging.info(f"{account_id}有计划:", li.__len__())
 | 
	
		
			
				|  |  |          sql = "replace into campaign_info values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
 | 
	
		
			
				|  |  |          db.quchen_text.executeMany(sql, li)
 | 
	
		
			
				|  |  |      db.close()
 | 
	
	
		
			
				|  | @@ -114,22 +114,22 @@ def get_adcreatives(account_id,access_token,flag,adc_ids,dt):  # 获取创意
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          while True:
 | 
	
		
			
				|  |  |              h = requests.get(url, params=parameters)
 | 
	
		
			
				|  |  | -            # print(h.json())
 | 
	
		
			
				|  |  | +            # logging.info(h.json())
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if h.status_code == 200:
 | 
	
		
			
				|  |  |                  r = h.json()
 | 
	
		
			
				|  |  | -                # print(r)
 | 
	
		
			
				|  |  | +                # logging.info(r)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  break
 | 
	
		
			
				|  |  |              else:
 | 
	
		
			
				|  |  |                  time.sleep(1)
 | 
	
		
			
				|  |  | -                print("爬取失败 等待1s")
 | 
	
		
			
				|  |  | +                logging.info("爬取失败 等待1s")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if 'data' in r.keys():
 | 
	
		
			
				|  |  |              is_video=0
 | 
	
		
			
				|  |  |              for i in r['data']['list']:
 | 
	
		
			
				|  |  | -                # print(i)
 | 
	
		
			
				|  |  | +                # logging.info(i)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if flag=='MP':
 | 
	
		
			
				|  |  |                      if len(i['adcreative_elements'])>0:
 | 
	
	
		
			
				|  | @@ -195,7 +195,7 @@ def get_adcreatives(account_id,access_token,flag,adc_ids,dt):  # 获取创意
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              break
 | 
	
		
			
				|  |  |      if len(li)>0:
 | 
	
		
			
				|  |  | -        print(f"{account_id}有创意:",len(li))
 | 
	
		
			
				|  |  | +        logging.info(f"{account_id}有创意:",len(li))
 | 
	
		
			
				|  |  |          sql='replace into adcreative_info values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) '
 | 
	
		
			
				|  |  |          db.quchen_text.executeMany(sql,li)
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -239,13 +239,13 @@ def images_info_get(account_id,access_token,image_ids):  # 获取图片信息
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          while True:
 | 
	
		
			
				|  |  |              h = requests.get(url, params=parameters)
 | 
	
		
			
				|  |  | -            # print(h.text)
 | 
	
		
			
				|  |  | +            # logging.info(h.text)
 | 
	
		
			
				|  |  |              if h.status_code == 200:
 | 
	
		
			
				|  |  |                  r = h.json()
 | 
	
		
			
				|  |  |                  break
 | 
	
		
			
				|  |  |              else:
 | 
	
		
			
				|  |  |                  time.sleep(1)
 | 
	
		
			
				|  |  | -                print("请求出错 等待1s..")
 | 
	
		
			
				|  |  | +                logging.info("请求出错 等待1s..")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if 'data' in r.keys():
 | 
	
		
			
				|  |  |              li.extend(r['data']['list'])
 | 
	
	
		
			
				|  | @@ -256,12 +256,12 @@ def images_info_get(account_id,access_token,image_ids):  # 获取图片信息
 | 
	
		
			
				|  |  |              page += 1
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              break
 | 
	
		
			
				|  |  | -    # print(li)
 | 
	
		
			
				|  |  | +    # logging.info(li)
 | 
	
		
			
				|  |  |      data = []
 | 
	
		
			
				|  |  |      for i in li:
 | 
	
		
			
				|  |  |          data.append((i['image_id'],i['width'],i['height'],i['signature'],i['preview_url']))
 | 
	
		
			
				|  |  | -    # print(data)
 | 
	
		
			
				|  |  | -    print(f"{account_id} 有图片:", li.__len__())
 | 
	
		
			
				|  |  | +    # logging.info(data)
 | 
	
		
			
				|  |  | +    logging.info(f"{account_id} 有图片:", li.__len__())
 | 
	
		
			
				|  |  |      if li.__len__() > 0:
 | 
	
		
			
				|  |  |          sql="replace into image_info value (%s,%s,%s,%s,%s)"
 | 
	
		
			
				|  |  |          db.quchen_text.executeMany(sql, data)
 | 
	
	
		
			
				|  | @@ -306,13 +306,13 @@ def video_info_get(account_id,access_token,image_ids):  # 获取视频信息
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          while True:
 | 
	
		
			
				|  |  |              h = requests.get(url, params=parameters)
 | 
	
		
			
				|  |  | -            # print(h.text)
 | 
	
		
			
				|  |  | +            # logging.info(h.text)
 | 
	
		
			
				|  |  |              if h.status_code == 200:
 | 
	
		
			
				|  |  |                  r = h.json()
 | 
	
		
			
				|  |  |                  break
 | 
	
		
			
				|  |  |              else:
 | 
	
		
			
				|  |  |                  time.sleep(1)
 | 
	
		
			
				|  |  | -                print("请求出错 等待1s..")
 | 
	
		
			
				|  |  | +                logging.info("请求出错 等待1s..")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if 'data' in r.keys():
 | 
	
		
			
				|  |  |              li.extend(r['data']['list'])
 | 
	
	
		
			
				|  | @@ -323,12 +323,12 @@ def video_info_get(account_id,access_token,image_ids):  # 获取视频信息
 | 
	
		
			
				|  |  |              page += 1
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              break
 | 
	
		
			
				|  |  | -    # print(li)
 | 
	
		
			
				|  |  | +    # logging.info(li)
 | 
	
		
			
				|  |  |      data = []
 | 
	
		
			
				|  |  |      for i in li:
 | 
	
		
			
				|  |  |          data.append((i['video_id'],i['width'],i['height'],i['signature'],i['preview_url']))
 | 
	
		
			
				|  |  | -    # print(data)
 | 
	
		
			
				|  |  | -    print(f"{account_id} 有视频:", li.__len__())
 | 
	
		
			
				|  |  | +    # logging.info(data)
 | 
	
		
			
				|  |  | +    logging.info(f"{account_id} 有视频:", li.__len__())
 | 
	
		
			
				|  |  |      if li.__len__() > 0:
 | 
	
		
			
				|  |  |          sql="replace into video_info value (%s,%s,%s,%s,%s)"
 | 
	
		
			
				|  |  |          db.quchen_text.executeMany(sql, data)
 | 
	
	
		
			
				|  | @@ -345,14 +345,14 @@ def ad_info():
 | 
	
		
			
				|  |  |      total_data =[]
 | 
	
		
			
				|  |  |      executor = ThreadPoolExecutor(max_workers=max_workers)
 | 
	
		
			
				|  |  |      for i in accounts:
 | 
	
		
			
				|  |  | -        # print(i)
 | 
	
		
			
				|  |  | +        # logging.info(i)
 | 
	
		
			
				|  |  |          account_id =i[0]
 | 
	
		
			
				|  |  |          access_token = i[1]
 | 
	
		
			
				|  |  |          type = i[3]
 | 
	
		
			
				|  |  |          executor.submit(get_ad_info,account_id, access_token,type,total_data)
 | 
	
		
			
				|  |  |      executor.shutdown()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    print(len(total_data))
 | 
	
		
			
				|  |  | +    logging.info(len(total_data))
 | 
	
		
			
				|  |  |      if len(total_data)>0:
 | 
	
		
			
				|  |  |          sql="replace into ad_info values(%s,%s,%s,%s,%s,%s,%s) "
 | 
	
		
			
				|  |  |          db.quchen_text.executeMany(sql, total_data)
 | 
	
	
		
			
				|  | @@ -399,7 +399,7 @@ def get_ad_info(account_id, access_token, flag,ad_ids,dt):
 | 
	
		
			
				|  |  |                  time.sleep(61)
 | 
	
		
			
				|  |  |              else:
 | 
	
		
			
				|  |  |                  break
 | 
	
		
			
				|  |  | -        # print(r)
 | 
	
		
			
				|  |  | +        # logging.info(r)
 | 
	
		
			
				|  |  |          total_page = r['data']['page_info']['total_page']
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if page > total_page:
 | 
	
	
		
			
				|  | @@ -414,7 +414,7 @@ def get_ad_info(account_id, access_token, flag,ad_ids,dt):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      if li.__len__()>0:
 | 
	
		
			
				|  |  | -        print(f"{account_id}有广告:",li.__len__())
 | 
	
		
			
				|  |  | +        logging.info(f"{account_id}有广告:",li.__len__())
 | 
	
		
			
				|  |  |          sql = "replace into ad_info values(%s,%s,%s,%s,%s,%s,%s,%s) "
 | 
	
		
			
				|  |  |          db.quchen_text.executeMany(sql, li)
 | 
	
		
			
				|  |  |      db.close()
 | 
	
	
		
			
				|  | @@ -457,7 +457,7 @@ def ad_cost_day_gdt(account_id,access_token,st,et):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          while True:
 | 
	
		
			
				|  |  |              r  = requests.get(url, params=parameters).json()
 | 
	
		
			
				|  |  | -        # print(r)
 | 
	
		
			
				|  |  | +        # logging.info(r)
 | 
	
		
			
				|  |  |              code =r['code']
 | 
	
		
			
				|  |  |              if code==11017:
 | 
	
		
			
				|  |  |                  time.sleep(61)
 | 
	
	
		
			
				|  | @@ -479,9 +479,9 @@ def ad_cost_day_gdt(account_id,access_token,st,et):
 | 
	
		
			
				|  |  |              break
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              page += 1
 | 
	
		
			
				|  |  | -    # print(li)
 | 
	
		
			
				|  |  | +    # logging.info(li)
 | 
	
		
			
				|  |  |      if len(li) > 0:
 | 
	
		
			
				|  |  | -        print(f"{account_id} have ad cost :{len(li)} ")
 | 
	
		
			
				|  |  | +        logging.info(f"{account_id} have ad cost :{len(li)} ")
 | 
	
		
			
				|  |  |          db.quchen_text.executeMany('replace into ad_cost_day values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)', li)
 | 
	
		
			
				|  |  |          db.close()
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -513,9 +513,9 @@ def ad_cost_day_mp(account_id,access_token,st,et):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          while True:
 | 
	
		
			
				|  |  |              r = requests.get(url, params=parameters).json()
 | 
	
		
			
				|  |  | -            # print(r['data']['list'])
 | 
	
		
			
				|  |  | +            # logging.info(r['data']['list'])
 | 
	
		
			
				|  |  |              # import pandas as pd
 | 
	
		
			
				|  |  | -            # print(pd.DataFrame(r['data']['list']))
 | 
	
		
			
				|  |  | +            # logging.info(pd.DataFrame(r['data']['list']))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              code = r['code']
 | 
	
		
			
				|  |  |              if code == 11017:
 | 
	
	
		
			
				|  | @@ -539,10 +539,10 @@ def ad_cost_day_mp(account_id,access_token,st,et):
 | 
	
		
			
				|  |  |              break
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              page += 1
 | 
	
		
			
				|  |  | -    # print(li)
 | 
	
		
			
				|  |  | +    # logging.info(li)
 | 
	
		
			
				|  |  |      # exit()
 | 
	
		
			
				|  |  |      if len(li) > 0:
 | 
	
		
			
				|  |  | -        print(f"{account_id} have ad cost :{len(li)} ")
 | 
	
		
			
				|  |  | +        logging.info(f"{account_id} have ad cost :{len(li)} ")
 | 
	
		
			
				|  |  |          db.quchen_text.executeMany('replace into ad_cost_day values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)', li)
 | 
	
		
			
				|  |  |          db.close()
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -586,7 +586,7 @@ def daily_reports_get(access_token, account_id, level, start_date, end_date, fie
 | 
	
		
			
				|  |  |              break
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  |              time.sleep(1)
 | 
	
		
			
				|  |  | -            print("请求出错 等待1s..")
 | 
	
		
			
				|  |  | +            logging.info("请求出错 等待1s..")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      return r.json()
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -652,10 +652,10 @@ def mysql_insert_adcreative(data):
 | 
	
		
			
				|  |  |          cursor.executemany(sql, data)
 | 
	
		
			
				|  |  |          db.commit()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        print('insert [adcreative] ', len(data))
 | 
	
		
			
				|  |  | +        logging.info('insert [adcreative] ', len(data))
 | 
	
		
			
				|  |  |      except:
 | 
	
		
			
				|  |  |          db.rollback()
 | 
	
		
			
				|  |  | -        print('insert [adcreative] defeat')
 | 
	
		
			
				|  |  | +        logging.info('insert [adcreative] defeat')
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 |