class YunQianBaoMan(TaskSet): def on_start(self): self.header = { "Connection": "keep-alive", "app-type": "android", #android "mobile-unid": str(int(round(time.time() * 100000))), "app-version": "5.5.4.1", "mobile-type": "HUAWEIALP-TL00(8.0.0)", "mobile-system": "android8.0.0", "device-tokens": "AkWsVNSPMcwhC6nAXITHbPyrv0YgG5nt1T0B8n79-lrN", # "User-Agent": random.choice( UserAgent.random_userAgent() ), #"Dalvik/2.1.0 (Linux; U; Android 8.0.0; ALP-TL00 Build/HUAWEIALP-TL00)", "Content-Type": "application/x-www-form-urlencoded", } self.apikey = "djakdgkadgkafddadfjaddgbadsbfhbdashbgfadssfhbh" # self.sfz_path = "F:/myTestFile/TestObject/YouTime/yunqianbao/static/shenfenzheng.txt" self.publicData = PublicDataClass(self) self.PengYou = PengYouClass(self) self.login_res = self.PengYou.login(self.apikey, self.header) #登录 @task def userShiMing(self): """ 1.登录 2.实名状态 3.抢红包 4.打开红包 """ # print("开始集合") # all_locusts_spawned.wait(timeout=60) #在此设置了集合点 # print("集合释放") if self.login_res: zhuangtai = self.publicData.getUserType(self.apikey, self.header, self.login_res) #实名状态 if zhuangtai and zhuangtai == 5: queryRes = self.publicData.queryPaymentPassword( self.apikey, self.header, self.login_res) #查询用户是否设置了交易密码 if not queryRes["paypwd_set"]: self.publicData.setPaymentPassword(self.apikey, self.header, self.login_res) #设置支付密码 group_id = "809" #群id hbid = self.PengYou.hairRedEnvelopes(self.apikey, self.header, self.login_res, group_id) #发红包
class YunQianBaoMan(TaskSet): def Setups(self): pass def TearDowns(self): pass def on_start(self): self.header = { "Connection": "keep-alive", "app-type": "android", #android "mobile-unid": str(int(round(time.time() * 100000))), "app-version": "5.4.91", "mobile-type": "HUAWEIALP-TL00(8.0.0)", "mobile-system": "android8.0.0", "device-tokens": "", #AkWsVNSPMcwhC6nAXITHbPyrv0YgG5nt1T0B8n79-lrN "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 8.0.0; ALP-TL00 Build/HUAWEIALP-TL00)", "Content-Type": "application/x-www-form-urlencoded", } self.apikey = "djakdgkadgkafddadfjaddgbadsbfhbdashbgfadssfhbh" self.sfz_path = "F:/myTestFile/TestObject/YouTime/yunqianbao/static/shenfenzheng.txt" self.public_Data = PublicDataClass(self) self.login_res = self.public_Data.login(self.apikey, self.header) #登录 def on_logout(self): self.public_Data.userLogout(self.apikey, self.header, self.login_res) @task def huoqurenwu(self): is_safe = self.public_Data.index(self.apikey, self.header, self.login_res) #获取首页 self.public_Data.setMiBao(self.apikey, self.header, self.login_res, is_safe) # 设置密保 taskdata = self.public_Data.getUserType(self.apikey, self.header, self.login_res) #获取用户实名状态 if taskdata["type"] == 3: print("实名认证信息已提交====待审核===={}".format(self.login_res)) elif taskdata["type"] == 1: self.public_Data.shiMing(self.apikey, self.header, self.login_res, self.sfz_path) #实名认证 else: pass taskdata = self.public_Data.getUserType(self.apikey, self.header, self.login_res) #查询用户实名状态 if taskdata and taskdata["type"] == 5: dqres = self.public_Data.getDangQiId(self.apikey, self.header, self.login_res) #获取当期id self.public_Data.comTask(self.apikey, self.header, self.login_res, dqres["periodId"]) #进入获取任务页 self.public_Data.getUserType(self.apikey, self.header, self.login_res) #实名状态 queryRes = self.public_Data.queryPaymentPassword( self.apikey, self.header, self.login_res) #查询用户是否设置了交易密码 if not queryRes["paypwd_set"]: self.public_Data.setPaymentPassword(self.apikey, self.header, self.login_res) #设置支付密码 money = self.public_Data.selectGoldShares(self.apikey, self.header, self.login_res) #查询账户余额 if money: self.public_Data.paymentTaskMoney(self.apikey, self.header, self.login_res) #支付任务押金