def userShiMing(self, mobile): """ 1.登录 2.首页 3.实名 4.实名状态 """ self.publicData = PublicDataClass(self) self.login_res = self.zhuCeAndlogin(self.apikey, self.header, mobile) #登录 is_safe = self.publicData.index(self.apikey, self.header, self.login_res) #获取首页 self.publicData.setMiBao(self.apikey, self.header, self.login_res, is_safe) # 设置密保 taskdata = self.publicData.getUserType(self.apikey, self.header, self.login_res) #查看实名状态/获取任务 if taskdata["type"] == 5: print("用户状态5====={}".format(taskdata["type"])) pass elif taskdata["type"] == 3: print("用户状态3====={}".format(taskdata["type"])) print("{}==需要去后台审核通过实名认证".format(self.login_res)) elif taskdata["type"] == 1: print("用户状态1====={}".format(taskdata["type"])) self.publicData.shiMing(self.apikey, self.header, self.login_res, self.sfz_path) #实名认证 else: print("用户状态?====={}".format(taskdata["type"])) self.publicData.userLogout(self.apikey, self.header, self.login_res)
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) #获取首页
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: # taskdata = self.publicData.getUserType(self.apikey,self.header,self.login_res) #查看实名状态/获取任务 # if taskdata == 5: gift_ids = ["547"] #红包id for gift_id in gift_ids: group_id = "809" #群id hb_respons = self.PengYou.robRedEnvelopes( self.apikey, self.header, self.login_res, gift_id) if hb_respons: if int(hb_respons["aic"]) == 0 and int( hb_respons["aic_receive"]) < int( hb_respons["aic_total"]): redEnvelopes = self.PengYou.openRedEnvelopes( self.apikey, self.header, self.login_res, gift_id, group_id) if redEnvelopes: if redEnvelopes["status"] == 200: print("抢到{}个aic".format( redEnvelopes["data"]["aic"])) elif redEnvelopes["status"] == 400: self.publicData.getUserType( self.apikey, self.header, self.login_res) #查看实名状态/获取任务
def userShiMing(self): """ 1.登录 2.首页 3.实名 4.实名状态 """ publicData = PublicDataClass(self) self.login_res = publicData.login(self.apikey,self.header) #登录 if self.login_res: # is_safe = self.publicData.index(self.apikey,self.header,self.login_res) #获取首页 # self.publicData.setMiBao(self.apikey, self.header,self.login_res,is_safe) # 设置密保 taskdata = publicData.getUserType(self.apikey,self.header,self.login_res) #查看实名状态/获取任务
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: taskdata = self.publicData.getUserType( self.apikey, self.header, self.login_res) #查看实名状态/获取任务
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) #登录
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.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", "app-type":"ios", "app-version":"5.6.1", "device-tokens":"324bf4fa8b6d8c37b98e86f6366833fa9f2b73df648ee83e062b660f0e19ad43", "Content-Type":"application/x-www-form-urlencoded", "mobile-unid":"c8eb9ab231654cb58a14bd24f9062781", "mobile-system":"12.4.8", "User-Agent":"(iPhone; iOS 12.4.8; Scale/2.00) YunZhangBen/5.6.1", "mobile-type":"iPhone 6" } self.apikey="djakdgkadgkafddadfjaddgbadsbfhbdashbgfadssfhbh" # self.sfz_path = "F:/myTestFile/TestObject/YouTime/yunqianbao/static/shenfenzheng.txt" self.publicData = PublicDataClass(self) self.rmhd = ReMenHuoDong(self) self.login_res = self.publicData.login(self.apikey,self.header) #登录 @task def tiJiaoShenQing(self): zmgddbres = self.rmhd.recruitingRepresentatives(self.apikey,self.header,self.login_res) #招募股东代表(申请状态) if zmgddbres: if zmgddbres["sub_status"] == "1": #申请成为股东代表 self.rmhd.submitApplication(self.apikey,self.header,self.login_res) #提交申请 elif zmgddbres["sub_status"] == "2": #已提交表决中 print("已提交表决中") elif zmgddbres["sub_status"] == "3":#表决未通过 重新申请 tjsqres = self.rmhd.ReSubmitApplication(self.apikey,self.header,self.login_res,zmgddbres["applyInfo"]["applyId"]) elif zmgddbres["sub_status"] == "8": print("邀请好友投票") elif zmgddbres["sub_status"] == "10":#已加入其它合作社 print("已加入其它合作社") else: print("状态未知===",zmgddbres["sub_status"])
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.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", "app-type": "ios", "app-version": "5.6.1", "device-tokens": "324bf4fa8b6d8c37b98e86f6366833fa9f2b73df648ee83e062b660f0e19ad43", "Content-Type": "application/x-www-form-urlencoded", "mobile-unid": "c8eb9ab231654cb58a14bd24f9062781", "mobile-system": "12.4.8", "User-Agent": "(iPhone; iOS 12.4.8; Scale/2.00) YunZhangBen/5.6.1", "mobile-type": "iPhone 6" } self.apikey = "djakdgkadgkafddadfjaddgbadsbfhbdashbgfadssfhbh" # self.sfz_path = "F:/myTestFile/TestObject/YouTime/yunqianbao/static/shenfenzheng.txt" self.publicData = PublicDataClass(self) self.rmhd = ReMenHuoDong(self) self.login_res = self.publicData.login(self.apikey, self.header) #登录
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) #支付任务押金
def zhuCeUser(self): self.header["mobile-unid"] = str(int(round(time.time() * 100000))) self.header["device-tokens"] = str(int(round(time.time() * 1000))) self.header["User-Agent"] = str(int(round(time.time() * 100000))) self.header["mobile-type"] = str(int(round(time.time() * 1000))) PublicDataClass(self).zhuceUser(self.apikey, self.header)
def userlogin(self): PublicDataClass(self).login(self.apikey, self.header)
def zhuCeUser(self): userdata = PublicDataClass(self).zhuceUser(self.apikey, self.header) if userdata: self.userShiMing(userdata["mobile"])
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.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" # @task def userShiMing(self, mobile): """ 1.登录 2.首页 3.实名 4.实名状态 """ self.publicData = PublicDataClass(self) self.login_res = self.zhuCeAndlogin(self.apikey, self.header, mobile) #登录 is_safe = self.publicData.index(self.apikey, self.header, self.login_res) #获取首页 self.publicData.setMiBao(self.apikey, self.header, self.login_res, is_safe) # 设置密保 taskdata = self.publicData.getUserType(self.apikey, self.header, self.login_res) #查看实名状态/获取任务 if taskdata["type"] == 5: print("用户状态5====={}".format(taskdata["type"])) pass elif taskdata["type"] == 3: print("用户状态3====={}".format(taskdata["type"])) print("{}==需要去后台审核通过实名认证".format(self.login_res)) elif taskdata["type"] == 1: print("用户状态1====={}".format(taskdata["type"])) self.publicData.shiMing(self.apikey, self.header, self.login_res, self.sfz_path) #实名认证 else: print("用户状态?====={}".format(taskdata["type"])) self.publicData.userLogout(self.apikey, self.header, self.login_res) # @task(1) # def userlogin(self): # PublicDataClass(self).login(self.apikey,self.header) @task(1) def zhuCeUser(self): userdata = PublicDataClass(self).zhuceUser(self.apikey, self.header) if userdata: self.userShiMing(userdata["mobile"]) # @task def zhuCeAndlogin(self, apikey, header, mobile): """" 登录 """ password = "******" #"e10adc3949ba59abbe56e057f20f883e" # device_tokens = "" #"AkWsVNSPMcwhC6nAXITHbPyrv0YgG5nt1T0B8n79-lrN" login_data = { "password": password, "latitude": "39.905662", "mobile": str(mobile), "long": "116.64063", "device_tokens": device_tokens, "timestamp": str(int(time.time())), "sign": "" } url = "v2/login/login-new" sign = GetDataSign().sign_body(url, login_data, apikey) login_data["sign"] = sign #登录 loginres = PublicRequest(self).requestMethod(url, login_data, header) loginresult = json.loads(loginres.text) if 'status' in loginresult and loginresult[ "status"] == 200 or 'status' in loginresult and loginresult[ "status"] == "200": time.sleep(random.randint(1, 3)) login_res = loginresult["data"] loginres.success() return login_res else: print("报错url==={} ,参数==={} ,报错原因==={}".format( url, login_data, loginresult)) loginres.failure("报错url==={} ,参数==={} ,报错原因==={}".format( url, login_data, loginresult))
def zhuCeUser(self,url,zc_data,header): PublicDataClass(self).zhuceUser(self.apikey,self.header)
def login(self, apikey, header): """" 登录》获取首页》判断密保(未设置密保先设置密保)》判断是否实名(未实名则先实名) """ try: mobile = self.user.queueData.get() #获取队列里的数据 except queue.Empty: #队列取空后,直接退出 print('no data exist') exit(0) password = "******" # device_tokens = int( round(time.time() * 1000)) #"AkWsVNSPMcwhC6nAXITHbPyrv0YgG5nt1T0B8n79-lrN" login_data = { "password": password, "latitude": "39.905662", "mobile": str(mobile), "long": "116.64063", "device_tokens": str(device_tokens), "timestamp": str(int(time.time())), "sign": "" } login_url = "v2/login/login2" sign = GetDataSign().sign_body(login_url, login_data, apikey) login_data["sign"] = sign #登录 with self.client.post(login_url, data=login_data, headers=header, verify=False, allow_redirects=False, catch_response=True) as loginres: print("登录===={}".format(loginres.elapsed.total_seconds())) # print("loginres===",loginres) if "[200]" in str(loginres): loginresult = json.loads(loginres.text) if 'status' in loginresult and loginresult[ "status"] == 200 or 'status' in loginresult and loginresult[ "status"] == "200": time.sleep(random.randint(1, 3)) login_res = loginresult["data"] print("登录成功啦") loginres.success() return login_res elif 'status' in loginresult and loginresult["status"] == 421: print("登录成功啦啊啦啦啦啦啦啦") loginres.success() time.sleep(random.randint(1, 3)) login_res = PublicDataClass(self).miBaoWenTi( apikey, header) return login_res elif 'status' in loginresult and loginresult["status"] == 412: print("请打开应用权限") #应用管理》进入app权限设置》应用权限》设置单项权限》获取手机识别码 loginres.failure("{}XXX===={}".format( str(mobile), password)) elif 'status' in loginresult and loginresult["status"] == 1006: print("用户名或密码错误") loginres.failure("{}XXX===={}".format( str(mobile), password)) else: print("报错url==={} ,参数==={} ,报错原因==={}".format( login_url, login_data, loginresult)) loginres.failure("报错url==={} ,参数==={} ,报错原因==={}".format( login_url, login_data, loginresult)) else: print("XXXXX登录出现意想不到的错误XXXXX") loginres.failure( "登录出现意想不到的错误报错url==={} ,参数==={} ,报错原因==={}".format( login_url, login_data, loginres.text))