def import_wx_flow_free(self, token=None, type=1, subject_id=280, subject_name='PHP'): """ 学员录入--导入(微信流量)--拥有【免费流量组】 """ if type == 1: data = self._data.get('student_input_import_for_wx_free') else: data = self._data.get('student_input_import_for_wx_free_perssion') url, method, header, params, shared, check = cotool.deal_data(data) excel = { "1": ['客户姓名', '手机号码', 'QQ号码', '微信号', 'QQ群'], "2": ['lily', '13012345678', '23121231', '123456', '123456'] } if token is None: if rc.get_env() == 'pre': token = login.login_action('t0322511032') else: token = login.login_action('m17673155297') file_data, content_type, file_path = oe.send_file(excel, params) header['content-type'] = content_type header['token'] = token params['subjectId'] = subject_id params['subjectName'] = subject_name res = httprequest(url, method, header, file_data) cotool.extract_variable(res, shared) cotool.assert_res(res, check) oe.delete(file_path)
def query_zt_info(self, isEnterpriseWx=0, **kwargs): ''' 查询载体信息 :param isEnterpriseWx: 载体类型,0微信 1企业微信 :param kwargs: 载体名称 vector=*** :return: ''' if isEnterpriseWx == 0: data = self._data.get('query_zt_info_for_person') url, method, header, params, shared, check = cotool.deal_data(data) params['isEnterpriseWx'] = isEnterpriseWx if kwargs: params = dict(params, **kwargs) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res else: data = self._data.get('query_zt_info_for_company') url, method, header, params, shared, check = cotool.deal_data(data) params['isEnterpriseWx'] = isEnterpriseWx if kwargs: params = dict(params, **kwargs) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def editor_flow(self, plan_name=None, gather_type=1, ad_type=1, channel_id=4, channel_name='知乎'): """ 广告计划--流量-编辑 (需要一个没有创建创意的计划才能编辑) :param plan_name: 计划名称 :param channel_name: 投放渠道名称,要与下面channel_ID对应 :param channel_id: 投放渠道 1,广点通 2,今日头条 3,哔哩哔哩 4,知乎 5,微博... :param ad_type: 广告类型,1,信息流 2,竞价 :param gather_type: 1,手机流量 2,qq流量 3,微信流量 :return: """ data = self._data.get('editor_flow') url, method, header, params, shared, check = cotool.deal_data(data) params['name'] = plan_name params['id'] = GLOBAL_VAR['adId'] params['gatherType'] = gather_type params['channelId'] = channel_id params['type'] = ad_type params['channelName'] = channel_name res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def delete_carrier(self, id): data = self._data.get('delete_carrier') url, method, header, params, shared, check = cotool.deal_data(data) url = url + str(id) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check)
def create_wc_ad_plan_for_model(self, put_model=1, channelId=4): data = self._data.get('create_wechat_ad_plant') url, method, header, params, shared, check = cotool.deal_data(data) params['putMode'] = put_model params['channelId'] = channelId res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def publish_web(self): """ 发布落地页 """ data = self._data.get('publish_website') url, method, header, params, shared, check = cotool.deal_data(data) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) return res
def put_record_query(self): """ 入库记录流量数据查询 """ data = self._data.get('query_put_flow_data') url, method, header, params, shared, check = cotool.deal_data(data) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check)
def ldy_list_data_query(self): """ 落地页数据列表统计查询 """ data = self._data.get('query_ldy_data') url, method, header, params, shared, check = cotool.deal_data(data) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) return res
def login_operation(self): ''' 登录运营后台 ''' url, method, header, params, shared, check = cotool.deal_data( self._data['login_operation']) header['cookie'] = self.cookie res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check)
def ad_idea_flow_data_query(self): """ 广告创意流量数据查询 """ data = self._data.get('query_ad_ideas_data') url, method, header, params, shared, check = cotool.deal_data(data) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def create_personal_wechat_ad_ideas(self): """ 创建个人微信广告创意 """ data = self._data.get('create_personal_wechat_ad_ideas') url, method, header, params, shared, check = cotool.deal_data(data) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def create_wc_ad_plan_for_reception(self): """ 创建微信广告计划-直线下发,接待投放模式 """ data = self._data.get('create_wechat_ad_plant_for_reception') url, method, header, params, shared, check = cotool.deal_data(data) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def create_qq_idea(self): ''' 创建QQ广告创意 :return: ''' data = self._data.get('create_qq_ad_ideas') url, method, header, params, shared, check = cotool.deal_data(data) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def add_personal_code_for_tools(self, **kwargs): """ 生成个人微信二维码,发布(工具使用) """ data = self._data.get('add_personal_code_for_tools') url, method, header, params, shared, check = cotool.deal_data(data) if kwargs: params = dict(params, **kwargs) res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) return res
def get_plan_id(self, gatherType=3): """ 获取微信广告计划ID """ data = self._data.get('get_plan_id') url, method, header, params, shared, check = cotool.deal_data(data) params['gatherType'] = gatherType res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def register_code(self): ''' 获取注册验证码 ''' self.login_operation() url, method, header, params, shared, check = cotool.deal_data( self._data['register_code']) header['cookie'] = self.cookie res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check)
def import_budget_error_data(self, file_name): ''' 导入异常投放预算数据 ''' data = self._data.get('import_budget_error_data') url, method, header, params, shared, check = cotool.deal_data(data) file_data, content_type, file_path = oe.send_others_file(file_name, params) header['content-type'] = content_type res = httprequest(url, method, header, file_data) cotool.extract_variable(res, shared) cotool.assert_res(res, check)
def del_ad_data(self, gatherType=1): ''' 删除广告数据 :return: ''' data = self._data.get('del_ad_data') url, method, header, params, shared, check = cotool.deal_data(data) params['gatherType'] = gatherType res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def creativity_pageList(self): ''' 广告创意查询 :return: ''' data = self._cct.get('creativity_pageList') url, method, header, params, shared, check = cotool.deal_data(data) token = login.login_action('t0383212689', '123456') header['token'] = token res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check)
def add_ad_plan(self): ''' 创建广告计划 :return: ''' data = self._cad.get('program_info_save') url, method, header, params, shared, check = cotool.deal_data(data) token = login.login_action('t0383212689', '123456') header['token'] = token res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check)
def import_qq_single(self, excel): ''' 导入qq单个广告流量数据 :return: ''' data = self._data['import_qq_single'] url, method, header, params, shared, check = cotool.deal_data(data) file_data, content_type, file_path = oe.send_file(excel, params) header['content-type'] = content_type res = httprequest(url, method, header, file_data) cotool.extract_variable(res, shared) cotool.assert_res(res, check) oe.delete(file_path)
def create_ad_idea(self, gatherType=1): ''' 创建广告创意 :param gatherType: 流量类型 1,手机流量 2,QQ流量 3,微信流量 :return: ''' data = self._data.get('create_ad_ideas') url, method, header, params, shared, check = cotool.deal_data(data) params['gatherType'] = gatherType res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def import_wx_batch_reception(self, excel): ''' 批量导入微信广告流量数据,接待投放模式 :return: ''' data = self._data['import_wx_batch_reception'] url, method, header, params, shared, check = cotool.deal_data(data) file_data, content_type, file_path = oe.send_file(excel, params) header['content-type'] = content_type res = httprequest(url, method, header, file_data) cotool.extract_variable(res, shared) cotool.assert_res(res, check) oe.delete(file_path)
def export_idea_flow(self, gather_type=1): """ 广告计划--流量-导出 :param gather_type: 1,手机流量 2,qq流量 3,微信流量 :return: """ data = self._data.get('export_idea_flow') url, method, header, params, shared, check = cotool.deal_data(data) params['gatherType'] = gather_type res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def flow_cost_mgt_import(self, excel): """ :param excel: excel文件头组成的list :return: """ data = self._data.get('flow_cost_mgt_import') url, method, header, params, shared, check = cotool.deal_data(data) file_data, content_type, file_path = oe.send_file(excel, params) header['content-type'] = content_type res = httprequest(url, method, header, file_data) cotool.extract_variable(res, shared) cotool.assert_res(res, check) oe.delete(file_path)
def get_ad_data_id(self, gatherType=1): ''' 获取广告数据id :param gatherType: 流量类型 1,手机流量,2,QQ流量 3,微信流量 :return: ''' self._data = get_data.get_yinhe_data('ad_module/ad_idea.yaml') ad_data = self._data.get('get_ad_data_id') url, method, header, params, shared, check = cotool.deal_data(ad_data) params['gatherType'] = gatherType res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check) return res
def get_idea_id_for_tools(self, gatherType=3, adid=None): ''' 获取创意ID(工具使用方法) :param gatherType: 流量类型 1,手机流量 2,qq流量 3,微信流量 :return: ''' self._data = get_data.get_yinhe_data('ad_module/ad_idea.yaml') data = self._data.get('get_ad_ideas_id_for_tools') url, method, header, params, shared, check = cotool.deal_data(data) params['gatherType'] = gatherType params['id'] = adid res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) return res
def import_public_account(self, excel): """ 批量导入公众号 :param excel: 需要导入的excel数据 :return: """ data = self._data['import_public_account'] url, method, header, params, shared, check = cotool.deal_data(data) file_data, content_type, file_path = oe.send_file(excel, params) header['content-type'] = content_type res = httprequest(url, method, header, file_data) cotool.extract_variable(res, shared) cotool.assert_res(res, check) oe.delete(file_path)
def send_consumer_single(self): ''' 录入手机单个广告消费数据接口 :return: ''' data = self._data['import_consumer_single'] url, method, header, params, shared, check = cotool.deal_data(data) token = login.login_action('t0383212689', '123456') header['token'] = token params['costDate'] = const.todayStartTimestamp # res = requests.post(url=url, headers=headers_from_data, data=file_data, verify=False).json() res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check)
def add_carrier(self, type=None, carrierNo=None): """ 新增载体 :param type: 1.微信载体 2.QQ群载体 3.企业微信载体 :return: """ data = self._data.get('add_carrier') url, method, header, params, shared, check = cotool.deal_data(data) if type: params['carriers'][0]['type'] = type if carrierNo: params['carriers'][0]['carrierNo'] = carrierNo res = httprequest(url, method, header, params) cotool.extract_variable(res, shared) cotool.assert_res(res, check)