async def do_tasks(self, session): """ :param session: :return: """ res = await self.request(session, 'healthyDay_getHomeData', { "appId": "1EFRXxg", "taskToken": "", "channelId": 1 }) if res['code'] != 0 or res['data']['bizCode'] != 0: println('{}, 获取任务列表失败!'.format(self.account)) return data = res['data']['result'] task_list = data['taskVos'] for task in task_list: task_name, task_type = task['taskName'], task['taskType'] if task_type == 14: # 邀请好友助力 code = task['assistTaskDetailVo']['taskToken'] println('{}, 助力码:{}'.format(self.account, code)) Code.insert_code(code_key=CODE_FLASH_SALE_BOX, code_val=code, account=self.account, sort=self.sort) continue await self.do_task(session, task)
async def run(self): """ :return: """ async with aiohttp.ClientSession(cookies=self.cookies, headers=self.headers) as session: self.farm_info = await self.init_for_farm(session=session) if not self.farm_info: println('{}, 无法获取农场数据, 退出程序!'.format(self.account)) return Code.insert_code(code_key=CODE_JD_FARM, code_val=self.farm_info['shareCode'], account=self.account, sort=self.sort) println('{}, 助力码:{}'.format(self.account, self.farm_info['shareCode'])) await self.do_daily_task(session) # 每日任务 await self.do_ten_water(session) # 浇水十次 await self.get_first_water_award(session) # 领取首次浇水奖励 await self.get_ten_water_award(session) # 领取十次浇水奖励 await self.get_water_friend_award(session) # 领取给好友浇水的奖励 await self.click_duck(session) # 点鸭子任务 await self.do_ten_water_again(session) # 再次浇水 await self.got_water(session) # 领水滴 await self.notify_result(session) # 结果通知
async def create_tuan(self, session): """ :return: """ tuan_info = await self.query_tuan_info(session) if tuan_info['isOpenTuan'] != 2: path = 'dreamfactory/tuan/CreateTuan' params = { 'activeId': self.active_id, 'isOpenApp': 1, '_stk': '_time,activeId,isOpenApp' } data = await self.request(session, path, params) if not data or data['ret'] != 0: println('{}, 开团失败!'.format(self.account)) return '' println('{}, 开团成功, 团ID:{}!'.format(self.account, data['tuanId'])) tuan_id = data['tuanId'] else: tuan_id = tuan_info['tuanId'] println('{}, 团ID:{}'.format(self.account, tuan_id)) Code.insert_code(code_key=CODE_JX_FACTORY_TUAN, code_val=tuan_id, sort=self.sort, account=self.account) return tuan_id
async def do_tasks(self, session, data): """ 做任务 :param session: :param data: 首页数据 :return: """ println('{}, 开始做任务...'.format(self.account)) for task in data['result']['taskVos']: task_type = task['taskType'] task_name = task['taskName'] task_status = task['status'] if task_status == 2: println('{}, 任务:《{}》今日已完成!'.format(self.account, task_name)) continue if task_type == 13: await self.sign(session, task) elif task_type == 14: code = task['assistTaskDetailVo']['taskToken'] println('{}, 助力码:{}'.format(self.account, code)) from db.model import Code Code.insert_code(code_key=CODE_SMASH_GOLDEN_EGG, account=self.account, code_val=code) elif task_type == 21: println('{}, 跳过任务: 《{}》!'.format(self.account, task_name)) continue else: await self.do_task(session, task)
async def get_share_code(self, session): """ :return: """ println('{}, 正在获取助力码!'.format(self.account)) data = await self._get_index_data(session) if not data: println('{}, 无法获取助力码!'.format(self.account)) return await asyncio.sleep(1) await self.request(session, 'signGroupHit', {'activeType': data['activityType']}) await asyncio.sleep(1) data = await self._get_index_data(session) if not data: println('{}, 无法获取助力码!'.format(self.account)) return code = data['shareCode'] + '@' + data['groupCode'] Code.insert_code(code_key=CODE_JD_GRAB_BEAN, code_val=code, account=self.account, sort=self.sort) println('{}, 助力码: {}'.format(self.account, code)) return code
async def init(self, session): """ 初始化 :return: """ println('{}, 正在初始化数据...'.format(self.account)) data = await self.request(session, 'initPetTown') if data['resultCode'] != '0': println('{}, 无法获取活动首页数据, {}!'.format(self.account, data['message'])) return False if data['userStatus'] == 0: println('{}, 萌宠活动未开启, 请手动去京东APP开启活动入口:我的->游戏与互动->查看更多开启!'.format(self.account)) if 'goodsInfo' not in data: println('{}, 暂未选购商品!'.format(self.account)) self.message += '【商品状态】暂未选择商品!\n' self.share_code = data['shareCode'] self.invite_code = data['inviteCode'] println('{}的互助码为:{}'.format(self.account, self.share_code)) println('{}的邀请码为:{}'.format(self.account, self.invite_code)) if self.share_code: # 保存助力码 Code.insert_code(code_key=CODE_CUT_PET, code_val=self.share_code, account=self.account, sort=self.sort) if data['petStatus'] == 5: println('{}, 已可兑换商品!'.format(self.account)) self.message += '【商品状态】已可兑换商品\n' if data['petStatus'] == 6: println('{}, 已领取红包, 但未继续领养新的物品!'.format(self.account)) self.message += '【商品状态】暂未领取新的物品!' return True
async def get_share_code(self, session): """ 获取助力码 :return: """ res = await self.get(session, 'signin/carveUp/carveUpInfo', { "groupId": "", "type": 2 }) if res.get('code') != '0': println('{}, 获取组队数据失败!'.format(self.account)) return if 'groupId' not in res['result']: println('{}, 开启队伍!'.format(self.account)) res = await self.get( session, 'signin/carveUp/openCarveUp', { "nickName": "", "nickHeadUrl": "", "wcUnionId": "", "openId": "", "formId": "", "type": 2, "traceId": int(time.time() * 1000) }) code = res['result']['groupId'] println('{}, 助力码:{}'.format(self.account, code)) Code.insert_code(code_key=CODE_DJ_BEAN_MANOR, code_val=code, account=self.account, sort=self.sort)
async def run(self): """ :return: """ await self.get_encrypt() async with aiohttp.ClientSession(cookies=self.cookies, headers=self.headers) as session: if not await self.init(session): println('{}, 无法初始化, 退出程序!'.format(self.account)) return if self.share_code: println('{}, 助力码:{}'.format(self.account, self.share_code)) Code.insert_code(code_key=CODE_JX_PASTURE, code_val=self.share_code, sort=self.sort, account=self.account) await self.get_daily_food(session) await self.sign(session) # 每日签到 await self.get_gold_from_bull(session) # 收牛牛金币 await self.buy_food(session) # 购买白菜 await self.feed(session) # 喂食 await self.mowing(session, max_times=20) # 割草20次 await self.sweep_chicken_legs(session, max_times=20) # 扫鸡腿20次 await self.do_tasks(session) # 做任务领奖励 await self.notify(session) # 通知
async def get_task_list(self, session): """ 获取任务列表 :param session: :return: """ data = await self.request(session, 'jdfactory_getTaskDetail') if not data or data['bizCode'] != 0: println('{}, 无法获取任务列表!'.format(self.account)) return task_list = data['result']['taskVos'] for task in task_list: if task['taskType'] == 14: # 互助码 self.code = task['assistTaskDetailVo']['taskToken'] Code.insert_code(code_key=CODE_JD_FACTORY, code_val=self.code, account=self.account, sort=self.sort) println('{}, 助力码:{}'.format(self.account, self.code)) task_list.remove(task) break return task_list
async def do_tasks(self, session): """ 获取任务列表 :param session: :return: """ data = await self.request( session, 'superBrandTaskList', { "source": "secondfloor", "activityId": self.activity_id, "assistInfoFlag": 1 }) if data.get('code') != 0: println('{}, 获取任务列表数据失败!'.format(self.account)) return None task_list = data['result']['taskList'] for task in task_list: if '助力' in task['assignmentName'] or '邀请' in task['assignmentName']: code_val = task['encryptAssignmentId'] + '@' + task['ext'][ 'assistTaskDetail']['itemId'] println('{}, 助力码:{}'.format(self.account, code_val)) Code.insert_code(code_key=CODE_JD_SUPER_BRAND, code_val=code_val, sort=self.sort, account=self.account) continue if not task['ext']: item_id = 'null' else: if 'followShop' in task['ext']: item_id = task['ext']['followShop'][0]['itemId'] elif 'assistTaskDetail' in task['ext']: item_id = task['ext']['assistTaskDetail']['itemId'] elif 'brandMemberList' in task['ext']: item_id = task['ext']['brandMemberList'][0]['itemId'] else: item_id = 'null' body = { "source": "secondfloor", "activityId": self.activity_id, "encryptProjectId": self.encrypt_project_id, "encryptAssignmentId": task['encryptAssignmentId'], "assignmentType": task['assignmentType'], "completionFlag": 1, "itemId": item_id, "actionType": 0 } res = await self.request(session, 'superBrandDoTask', body) println('{}, 任务:{}, {}'.format(self.account, task['assignmentName'], res.get('msg')))
async def get_share_code(self, task): """ 获取助力码 :param task: :return: """ code = task['assistTaskDetailVo']['taskToken'] println('{}, 助力码:{}!'.format(self.account, code)) Code.insert_code(code_key=self.code_key, code_val=code, account=self.account, sort=self.sort)
async def get_share_code(self, session): """ 获取助力码 :param session: :return: """ res = await self.request(session, 'jdhealth_getTaskDetail', {"buildingId": "", "taskId": 6, "channelId": 1}) if res.get('bizCode', ERRCODE_DEFAULT) != 0: println('{}, 无法获取助力码!'.format(self.account)) return code = res['result']['taskVos'][0]['assistTaskDetailVo']['taskToken'] println('{}, 助力码:{}'.format(self.account, code)) Code.insert_code(code_key=CODE_JD_HEALTH, code_val=code, account=self.account, sort=self.sort)
async def get_share_code(self, session): """ :return: """ res = await self.request(session, {"apiMapping": "/active/shareUrl"}) if res.get('code') != 200: return code = res.get('data') println('{}, 助力码:{}'.format(self.account, code)) Code.insert_code(code_key=CODE_5G_BOX, code_val=code, sort=self.sort, account=self.account)
async def get_share_code(self, task): """ 获取助力码 """ body = { 'taskId': task['taskId'], 'uniqueId': task['uniqueId'], 'assistTargetPin': self.dj_pin, } code = json.dumps(body) Code.insert_code(code_key=CODE_DJ_FRUIT, code_val=code, account=self.account, sort=self.sort) println('{}, 助力码:{}'.format(self.account, code)) return code
async def get_share_code(self, session): """ 获取助力码 :return: """ data = await self.post(session=session, function_id='plantBeanIndex') if not data or data['code'] != '0' or 'errorMessage' in data: println('{}, 获取助力码失败:{}'.format(self.account, data.get('errorMessage', '未知'))) return None share_url = furl(data['data']['jwordShareInfo']['shareUrl']) code = share_url.args.get('plantUuid', '') println('{} 助力码:{}'.format(self.account, code)) Code.insert_code(code_key=CODE_PLANTING_BEAN, code_val=code, account=self.account, sort=self.sort) return code
async def do_tasks(self, session): """ 做任务 :return: """ res = await self.request(session, '/luckdraw/queryMissionList', [{ "userNo": "$cooMrdGatewayUid$", "activity_code": self.activity_code }]) if not res.get('success'): println('{}, 获取任务列表失败!'.format(self.account)) return task_list = res['content']['missionList'] for task in task_list: if task['status'] == 10: println('{}, 今日完成任务:{}!'.format(self.account, task['title'])) continue if task['status'] == 11: for no in task['getRewardNos']: body = [{ "activity_code": self.activity_code, "userNo": "$cooMrdGatewayUid$", "getCode": no }] res = await self.request(session, '/luckDraw/getDrawChance', body) if res.get('success'): println('{}, 成功领取一次抽奖机会!'.format(self.account)) break continue if '邀请' in task['title']: # 邀请好友 code = task['missionNo'] println('{}, 助力码:{}'.format(self.account, code)) Code.insert_code(code_val=code, code_key=CODE_KEY, sort=self.sort, account=self.account) continue for i in range(task['completeNum'], task['totalNum']): body = [{ "activity_code": self.activity_code, "userNo": "$cooMrdGatewayUid$", "missionNo": task['missionNo'], "params": task['params'] }] res = await self.request(session, '/luckDraw/completeMission', body) if res.get('success'): println('{}, 完成任务:{}-{}'.format(self.account, task['title'], i + 1)) await asyncio.sleep(1)
async def get_share_code(self, session): """ 获取助力码 :return: """ body = {"apiMapping": "/khc/task/getSupport"} res = await self.request(session, 'carnivalcity_jd_prod', body) if res.get('code') != 200: println('{}, 无法获取助力码!'.format(self.account)) return share_code = res.get('data', dict()).get('shareId') Code.insert_code(code_key=CODE_JD_CARNIVAL_CITY, code_val=share_code, sort=self.sort, account=self.account) println('{}, 助力码:{}'.format(self.account, share_code))
async def login(self, session, output=True): """ 获取用户信息 :param output: :param session: :return: """ params = { "sharePin": "", "shareType": 1, "channelLV": "", "source": 0, "riskDeviceParam": "{}" } data = await self.post(session, 'login', params) if not data or data['code'] != '200': if output: println('{}, 无法获取用户数据!'.format(self.account)) return False data = data['data'] if 'realName' not in data or not data['realName']: if output: self.message = '【活动名称】金果摇钱树\n【京东账号】{}\n【温馨提示】此账号未实名认证或者未参与过此活动: \n ①如未参与活动,' \ '请先去京东app参加摇钱树活动入口:我的->游戏与互动->查看更多\n②如未实名认证,请进行实名认证!\n'.\ format(unquote(self.account)) println(self.message) return False self.nickname = data['nick'] self.tree_name = data['treeInfo']['treeName'] self.tree_level = data['treeInfo']['level'] self.code = data['sharePin'] self.user_id = data['userInfo'] self.user_token = data['userToken'] self.fruit = data['treeInfo']['fruit'] self.jt_rest = data['jtRest'] if self.code: Code.insert_code(code_key=CODE_MONEY_TREE, code_val=self.code, account=self.account, sort=self.sort) return True
async def get_share_code(self, session): """ 获取助力码 :return: """ res = await self.request(session, 'MangHeApi/newShare', [{ "userNo": "$cooMrdGatewayUid$" }]) code = res.get('data', None) if code: println('{}, 助力码:{}'.format(self.account, code)) Code.insert_code(code_key=CODE_AMUSEMENT_POST, code_val=code, account=self.account, sort=self.sort) return code
async def init(self, session): """ 初始化 """ user_info = await self.get_user_info(session) if not user_info: return False if 'factoryList' not in user_info or not user_info['factoryList']: self.message = '\n【活动名称】京喜工厂\n【京东账号】{}\n【活动未开启】请前往京喜APP-我的-京喜工厂开启活动并选择商品!'.format( self.account) return False self.factory_id = user_info['factoryList'][0]['factoryId'] if 'productionList' not in user_info or not user_info['productionList']: println('{}, 未选择商品!'.format(self.account)) else: self.inserted_electric = user_info['productionList'][0][ 'investedElectric'] self.need_electric = user_info['productionList'][0]['needElectric'] self.production_id = user_info['productionList'][0]['productionId'] self.commodity_dim_id = user_info['productionList'][0][ 'commodityDimId'] self.production_stage_progress = round( (self.inserted_electric / self.need_electric) * 100, 2) if 'user' not in user_info: println('{}, 没有找到用户信息!'.format(self.account)) return False await asyncio.sleep(0.5) await self.query_production_name(session) self.pin = user_info['user']['pin'] self.phone_id = user_info['user']['deviceId'] self.encrypt_pin = user_info['user']['encryptPin'] self.nickname = user_info['user']['nickname'] println('{}, 助力码:{}'.format(self.account, self.encrypt_pin)) Code.insert_code(code_key=CODE_JX_FACTORY_WORK, code_val=self.encrypt_pin, sort=self.sort, account=self.account) self.active_id = await self.get_active_id(session) return True
async def get_share_code(self, session): """ 获取助力码 :return: """ data = await self.request(session, 'cash_getJDMobShareInfo', {"source": 2}) if data['code'] != 0 or data['data']['bizCode'] != 0: return None else: data = data['data']['result'] share_code = data['inviteCode'] + '@' + data['shareDate'] println('{}, 助力码:{}'.format(self.account, share_code)) Code.insert_code(code_key=CODE_JD_CASH, code_val=share_code, account=self.account, sort=self.sort) return share_code
async def do_tasks(self, session, task_list): """ 做任务 """ println('{}, 正在做任务!'.format(self.account)) for task in task_list: task_token = re.search(r"'taskToken': '(.*?)'", str(task)).group(1) if task['status'] == 2: println('{}, 任务:《{}》今日已完成!'.format(self.account, task['taskName'])) continue if task['taskType'] == 14: res = re.search(r"'taskToken': '(.*?)'", str(task)) if not res: println('{}, 获取助力码失败!'.format(self.account)) else: code = res.group(1) println('{}, 助力码:{}!'.format(self.account, code)) Code.insert_code(code_key=CODE_WISHING_POOL, code_val=code, account=self.account, sort=self.sort) continue if task['maxTimes'] > 1: await self.do_browse_task(session, task) else: await self.finish_task(session, task_token, task['taskId'], task['taskName']) res = await self.request( session, 'harmony_collectScore', { "appId": "1E1NXxq0", "taskToken": task_token, "taskId": task['taskId'], "actionType": 0 }) if res['bizCode'] != 0: println('{}, 领取任务:《{}》奖励失败!'.format(self.account, task['taskName'])) else: println('{}, 领取任务:《{}》奖励成功, 获得金币:{}!'.format( self.account, task['taskName'], res['result']['score']))
async def get_share_code(self, session): """ 获取助力码 :param session: :return: """ res = await self.request(session, 'h5activityIndex') data = res.get('result', None) if not data: return False code = data['redpacketInfo'].get('id', None) if not code: res = await self.request(session, 'h5launch', {"clientInfo": {}, "followShop": 0}) if res.get('biz_code') == 0: code = res['result']['redPacketId'] if not code: println('{}, 获取助力码失败!'.format(self.account)) else: Code.insert_code(code_key=CODE_KEY, code_val=code, account=self.account, sort=self.sort) println('{}, 助力码:{}'.format(self.account, code))