Exemple #1
0
    async def click_jd_electric(self, session, task):
        """
        京东首页点击京东电器
        :param session:
        :param task:
        :return:
        """
        println('{}, 正在进行任务:{}!'.format(self.account, task['taskName']))
        try:
            url = 'https://api.m.jd.com/?client=wh5&clientVersion=1.0.0&functionId=queryVkComponent&body=%7B' \
                  '%22businessId%22%3A%22babel%22%2C%22componentId%22%3A%224f953e59a3af4b63b4d7c24f172db3c3%22%2C' \
                  '%22taskParam%22%3A%22%7B%2522actId%2522%3A%25228tHNdJLcqwqhkLNA8hqwNRaNu5f%2522%7D%22%7D' \
                  '&_timestamp=1625621328362'
            response = await session.post(url)
            text = await response.text()
            data = json.loads(text)
            if data['code'] != '0':
                println('{}, 无法完成任务:{}!'.format(self.account, task['taskName']))
                return
        except Exception as e:
            println('{}, 无法完成任务:{}, {}!'.format(self.account, task['taskName'], e.args))
            return

        await asyncio.sleep(1)

        data = await self.request(session, 'jdfactory_collectScore',
                                  {'taskToken': task['simpleRecordInfoVo']['taskToken']})

        if data['bizCode'] != 0:
            println('{}, 无法完成任务:{}!'.format(self.account, task['taskName']))
        else:
            println('{}, 完成任务:{}, 获得电量:{}!'.format(self.account, task['taskName'], data['result']['score']))
Exemple #2
0
    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)  # 结果通知
Exemple #3
0
 async def run_help(self):
     """
     助力入口
     :return:
     """
     async with aiohttp.ClientSession(cookies=self.cookies,
                                      headers=self.headers) as session:
         item_list = Code.get_code_list(self.code_key)
         item_list.extend(get_code_list(self.code_key))
         for item in item_list:
             friend_account, friend_code = item.get('account'), item.get(
                 'code')
             if friend_account == self.account:
                 continue
             res = await self.request(
                 session, 'harmony_collectScore', {
                     "appId": self.appid,
                     "taskToken": friend_code,
                     "taskId": 4,
                     "actionType": 1,
                 })
             if res.get('bizCode', -1) != 0:
                 println('{}, 助力好友:{}失败, {}'.format(self.account,
                                                    friend_account,
                                                    res['bizMsg']))
                 if res['bizCode'] == 108:  # 助力已上限
                     break
             else:
                 println('{}, 成功助力好友:{}!'.format(self.account,
                                                 friend_account))
             await asyncio.sleep(1)
Exemple #4
0
    async def help_friend(self, session):
        """
        :param session:
        :return:
        """
        session.headers.add(
            'Referer',
            'https://h5.m.jd.com/babelDiy/Zeus/GzY6gTjVg1zqnQRnmWfMKC4PsT1/index.html'
        )

        item_list = Code.get_code_list(code_key=CODE_JD_CASH)
        item_list.extend(get_code_list(CODE_JD_CASH))
        for item in item_list:
            friend_account, friend_code = item.get('account'), item.get('code')
            if friend_account == self.account:
                continue

            invite_code, share_date = friend_code.split('@')

            data = await self.request(session, 'cash_mob_assist', {
                "inviteCode": invite_code,
                "shareDate": share_date,
                "source": 2
            })
            if data['code'] != 0 or data['data']['bizCode'] != 0:
                println('{}, 助力好友:{}失败, {}!'.format(self.account, invite_code,
                                                    data['data']['bizMsg']))
                if data['data']['bizCode'] in [206, 188]:  # 助力次数用完/活动太火爆了
                    break
            else:
                println('{}, 助力好友:{}成功!'.format(self.account, invite_code))

            await asyncio.sleep(2.5)
Exemple #5
0
    async def do_task(self, session):
        """
        做任务
        :return:
        """
        path = 'pet/getPetTaskConfig'
        task_list = await self.request(session, path)
        if not task_list:
            println('{}, 获取任务列表失败!'.format(self.account))
            return

        for task in task_list:
            if task['receiveStatus'] == 'unreceive':
                await self.get_award(session, task)
                await asyncio.sleep(1)

            if task['joinedCount'] and task['joinedCount'] >= task['taskChance']:
                println('{}, 任务:{}今日已完成!'.format(self.account, task['taskName']))
                continue

            if task['taskType'] == 'SignEveryDay':
                await self.sign_every_day(session, task)

            elif task['taskType'] == 'FollowGood':  # 关注商品
                await self.follow_good(session, task)

            elif task['taskType'] == 'FollowChannel':  # 关注频道
                await self.follow_channel(session, task)

            elif task['taskType'] == 'FollowShop':  # 关注店铺
                await self.follow_shop(session, task)

            elif task['taskType'] == 'ScanMarket':  # 逛会场
                await self.scan_market(session, task)
 async def get_bean_detail(self, session, page=1, timeout=0.5):
     """
     获取京豆详情页数据
     :param timeout:
     :param page:
     :param session:
     :return:
     """
     try:
         session.headers.add('Host', 'api.m.jd.com')
         session.headers.add('Content-Type',
                             'application/x-www-form-urlencoded')
         await asyncio.sleep(timeout)
         url = 'https://api.m.jd.com/client.action?functionId=getJingBeanBalanceDetail'
         body = 'body={}&appid=ld'.format(
             quote(json.dumps({
                 "pageSize": "20",
                 "page": str(page)
             })))
         response = await session.post(url=url, data=body)
         text = await response.text()
         data = json.loads(text)
         return data['detailList']
     except Exception as e:
         println('{}, 获取服务器数据失败, {}!'.format(self.account, e.args))
         return []
Exemple #7
0
    async def follow_shop(self, session, task):
        """
        关注店铺
        """
        click_path = 'pet/icon/click'
        shop_list = task['followShops']
        for shop in shop_list:
            click_params = {
                'iconCode': 'follow_shop',
                'linkAddr': shop['shopId']
            }
            await self.request(session, click_path, click_params)
            await asyncio.sleep(0.5)

            follow_path = 'pet/followShop'
            follow_params = {'shopId': shop['shopId']}
            data = await self.request(session,
                                      follow_path,
                                      follow_params,
                                      post_type='body',
                                      method='POST')
            if not data or 'success' not in data:
                println('{}, 无法关注店铺{}'.format(self.account, shop['name']))
            else:
                println('{}, 成功关注店铺: {}'.format(self.account, shop['name']))
            await asyncio.sleep(1)
Exemple #8
0
    async def do_task(self, session, task):
        """
        做任务
        :param task:
        :param session:
        :return:
        """
        if task['completedTimes'] >= task['targetTimes']:
            println('{}, 任务《{}》今日已完成!'.format(self.account, task['taskName']))
            return

        path = 'newtasksys/newtasksys_front/DoTask'
        params = {
            'source': 'dreamfactory',
            'bizCode': 'dream_factory',
            '_stk': '_time,bizCode,configExtra,source,taskId',
            'taskId': task['taskId'],
            'configExtra': ''
        }
        for i in range(task['completedTimes'], task['targetTimes']):
            data = await self.request(session, path, params)
            if not data or data['ret'] != 0:
                break
            await asyncio.sleep(1)
            await self.get_task_award(session, task)
Exemple #9
0
 async def request(self, session, path, params, method='GET'):
     """
     """
     try:
         time_ = datetime.now()
         default_params = {
             '_time': int(time_.timestamp() * 1000),
             'g_ty': 'ls',
             'callback': '',
             'sceneval': '2',
             'g_login_type': '1',
             '_': int(time_.timestamp() * 1000) + 2,
             '_ste': '1',
             'timeStamp': int(time.time() * 1000),
         }
         params.update(default_params)
         url = self.host + path + '?' + urlencode(params)
         h5st = await self.encrypt(time_, url)
         params['h5st'] = h5st
         url = self.host + path + '?' + urlencode(params)
         if method == 'GET':
             response = await session.get(url=url)
         else:
             response = await session.post(url=url)
         text = await response.text()
         data = json.loads(text)
         if data['ret'] != 0:
             return data
         else:
             result = data['data']
             result['ret'] = 0
             return result
     except Exception as e:
         println('{}, 请求服务器数据失败:{}'.format(self.account, e.args))
         return {'ret': 50000, 'msg': '请求服务器失败'}
Exemple #10
0
    async def query_work_info(self, session):
        """
        查询招工/打工情况
        :param session:
        :return:
        """
        path = 'dreamfactory/friend/QueryFriendList'
        params = {
            'body': '',
            '_stk': '_time,zone',
            'zone': 'dream_factory',
        }
        data = await self.request(session, path, params)
        if not data:
            return
        println('{}, 今日帮好友打工:{}/{}次!'.format(self.account,
                                             len(data['assistListToday']),
                                             data['assistNumMax']))

        # 打工次数满了,无法打工
        if len(data['assistListToday']) >= data['assistNumMax']:
            self.can_help = False

        println('{}, 今日招工:{}/{}次!'.format(self.account,
                                          len(data['hireListToday']),
                                          data['hireNumMax']))
Exemple #11
0
    async def do_task_list(self, session):
        """
        获取任务列表
        :param session:
        :return:
        """
        path = 'newtasksys/newtasksys_front/GetUserTaskStatusList'
        params = {
            'bizCode': 'dream_factory',
            'source': 'dream_factory',
            '_stk': '_time,bizCode,source'
        }
        data = await self.request(session, path, params)
        if not data or data['ret'] != 0:
            println('{}, 获取任务列表失败!'.format(self.account))
            return
        task_list = data['userTaskStatusList']

        for task in task_list:
            # 任务完成并且没有领取过奖励去领取奖励
            if task['completedTimes'] >= task['targetTimes'] and task[
                    'awardStatus'] != 1:
                await self.get_task_award(session, task)
                await asyncio.sleep(1)
                continue

            if task['taskType'] in [2, 9]:
                await self.do_task(session, task)
                await asyncio.sleep(1)
Exemple #12
0
 async def help_friend(self, session):
     """
     :param session:
     :return:
     """
     path = 'dreamfactory/userinfo/GetUserInfo'
     body = {
         'zone':
         'dream_factory',
         'pin':
         '',
         'sharePin':
         '',
         'shareType':
         2,
         'materialTuanPin':
         '',
         'materialTuanId':
         '',
         'source':
         '',
         '_stk':
         '_time,materialTuanId,materialTuanPin,pin,sharePin,shareType,source,zone'
     }
     item_list = Code.get_code_list(CODE_JX_FACTORY_WORK)
     item_list.extend(get_code_list(CODE_JX_FACTORY_WORK))
     for item in item_list:
         account, code = item.get('account'), item.get('code')
         if account == self.account:
             continue
         body['sharePin'] = code
         res = await self.request(session, path, body)
         msg = res.get('assistCondition',
                       dict()).get('assistConditionMsg', '未知')
         println('{}, 助力好友:{}, {}'.format(self.account, account, msg))
Exemple #13
0
    async def insert_electricity(self, session):
        """
        电量超过300万则加电一次, 满足兑换商品时全投
        :return:
        """
        data = await self.request(session, 'jdfactory_getHomeData')
        if not data or data['bizCode'] != 0:
            println('{}, 无法获取电量数据!'.format(self.account))
            return

        # 当前存储的电量
        cur_electricity = data['result']['factoryInfo']['remainScore']
        total_electricity = data['result']['factoryInfo']['totalScore']  # 兑换商品总共需要电量
        used_electricity = data['result']['factoryInfo']['useScore']  # 当前投入电量

        if int(cur_electricity) >= 300 * 10000:  # 电量已存满,加电一次
            data = await self.request(session, 'jdfactory_addEnergy')
            if data or data['bizCode'] != 0:
                println('{}, 成功失败!'.format(self.account))
            else:
                println('{}, 成功加电1次!'.format(self.account))

        # 电量足够换到商品, 全加
        if int(cur_electricity) + int(used_electricity) >= int(total_electricity):
            while True:
                data = await self.request(session, 'jdfactory_addEnergy')
                if data or data['bizCode'] != 0:
                    println('{}, 成功失败!'.format(self.account))
                    break
                else:
                    println('{}, 成功加电1次!'.format(self.account))
                await asyncio.sleep(2)
Exemple #14
0
    async def request(self, session, function_id=None, params=None, method='post'):
        """
        :param params:
        :param function_id:
        :param session:
        :param method:
        :return:
        """
        if params is None:
            params = {}
        try:
            session.headers.add('Content-Type', 'application/x-www-form-urlencoded')
            url = self.host + '?functionId={}&body={}&client=wh5&clientVersion=1.0.0'.format(function_id,
                                                                                              quote(json.dumps(params)))
            if method == 'post':
                response = await session.post(url=url)
            else:
                response = await session.get(url=url)

            text = await response.text()

            data = json.loads(text)

            if data['code'] != 0:

                return None
            else:
                return data['data']

        except Exception as e:
            println('{}, 请求服务器数据失败, {}'.format(self.account, e.args))
            return None
 async def get_bean_amount(self, session, timeout=0.5):
     """
     获取当前京豆总数
     :param timeout:
     :param session:
     :return:
     """
     try:
         println('{}, 正在获取京豆总数...'.format(self.account, timeout))
         await asyncio.sleep(timeout)
         url = 'https://me-api.jd.com/user_new/info/GetJDUserInfoUnion'
         session.headers.add('Host', 'me-api.jd.com')
         session.headers.add(
             'Referer',
             'https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&')
         response = await session.get(url)
         text = await response.text()
         data = json.loads(text)
         if data['retcode'] == '0' and 'data' in data and 'assetInfo' in data[
                 'data']:
             return int(data['data']['assetInfo']['beanNum'])
         else:
             return 0
     except Exception as e:
         println('{}, 获取京豆总数失败:{}!'.format(self.account, e.args))
         return 0
Exemple #16
0
    async def hire_award(self, session):
        """
        收取招工电量
        :param session:
        :return:
        """
        query_path = 'dreamfactory/friend/QueryHireReward'
        query_body = {'zone': 'dream_factory', '_stk': '_time,zone'}
        res = await self.request(session, query_path, query_body)

        item_list = res.get('hireReward', [])

        for item in item_list:
            path = 'dreamfactory/friend/HireAward'
            body = {
                'zone': 'dream_factory',
                'date': item['date'],
                'type': item['type'],
                '_stk': '_time,date,type,zone'
            }
            res = await self.request(session, path, body)

            if res.get('ret', -1) == 0:
                println('{}, 成功收取招工电量!'.format(self.account))
            else:
                println('{}, 收取招工电量失败, {}!'.format(self.account,
                                                   res.get('msg', '原因未知')))

            await asyncio.sleep(1)
    async def total_red_packet(self, session):
        """
        统计红包
        :param session:
        :return:
        """
        res = {
            'total_amount': 0,
            'expire_amount': 0,
        }
        try:
            session.headers.add(
                'Referer',
                'https://st.jingxi.com/my/redpacket.shtml?newPg=App&jxsid'
                '=16156262265849285961')
            session.headers.add('Host', 'm.jingxi.com')

            url = 'https://m.jingxi.com/user/info/QueryUserRedEnvelopesV2?type=1&orgFlag=JD_PinGou_New&page=1' \
                  '&cashRedType=1&redBalanceFlag=1&channel=1&_={}' \
                  '&sceneval=2&g_login_type=1&g_ty=ls'.format(int(time.time() * 1000))

            response = await session.get(url=url)
            text = await response.text()
            data = json.loads(text)
            if data['errcode'] != 0:
                return res
            res['total_amount'] = data['data']['balance'].strip()
            res['expire_amount'] = data['data']['expiredBalance'].strip()
            return res

        except Exception as e:
            println('{}, 获取红包数据失败:{}!'.format(self.account, e.args))
            return res
Exemple #18
0
    async def daily_sign(self, session):
        """
        每日签到
        :param session:
        :return:
        """
        data = await self.get_index_data(session)
        if 'data' not in data or 'floorInfoList' not in data['data']:
            println('{}, 无法获取签到数据:{}'.format(self.account, data))
            return

        sign_info = None

        for floor_info in data['data']['floorInfoList']:
            if 'code' in floor_info and floor_info['code'] == 'SIGN_ACT_INFO':
                cursor = floor_info['floorData']['signActInfo'][
                    'currSignCursor']
                token = floor_info['token']
                sign_info = {
                    'status': '',
                    'body': {
                        "floorToken": token,
                        "dataSourceCode": "signIn",
                        "argMap": {
                            "currSignCursor": cursor
                        }
                    }
                }
                for item in floor_info['floorData']['signActInfo'][
                        'signActCycles']:
                    if item['signCursor'] == cursor:
                        sign_info['status'] = item['signStatus']

        if not sign_info:
            println('{}, 查找签到数据失败, 无法签到!'.format(self.account))
            return

        if sign_info['status'] != -1:
            println('{}, 当前状态无法签到, 可能已签到过!'.format(self.account))
            return

        # 签到参数
        sign_params = {
            't': int(time.time() * 1000),
            'functionId': 'pg_interact_interface_invoke',
            'appid': 'sharkBean',
            'body': sign_info['body'],
        }

        res = await self.request(session, sign_params, self.METHOD_POST)
        if res.get('success', False):
            println('{}, 签到成功!'.format(self.account))
            for reward in res['data']['rewardVos']:
                if reward['jingBeanVo'] is not None:
                    self.bean_count += int(reward['jingBeanVo']['beanNum'])
                if reward['hongBaoVo'] is not None:
                    self.red_packet_num = float(self.red_packet_num) + float(
                        reward['hongBaoVo'])
        else:
            println('{}, 签到失败!'.format(self.account))
    async def get_expire_bean(self, session, timeout=0.5):
        """
        :param timeout:
        :param session:
        :return:
        """
        try:
            println('{}, 正在获取即将过期京豆数据...'.format(self.account, timeout))
            await asyncio.sleep(timeout)
            session.headers.add(
                'Referer',
                'https://wqs.jd.com/promote/201801/bean/mybean.html')
            session.headers.add('Host', 'wq.jd.com')
            session.headers.add('Content-Type',
                                'application/x-www-form-urlencoded')
            url = 'https://wq.jd.com/activep3/singjd/queryexpirejingdou?_={}&g_login_type=1&sceneval=2'.\
                format(int(time.time()*1000))
            response = await session.get(url=url)
            text = await response.text()
            data = json.loads(text[23:-13])
            res = []

            for item in data['expirejingdou']:
                amount = item['expireamount']
                if amount == 0:
                    continue
                msg = '【{}即将过期京豆】:{}'.format(
                    moment.unix(item['time']).zero.format('YYYY-M-D'), amount)
                res.append(msg)
            return res
        except Exception as e:
            println('{}, 获取即将过期的京豆数据失败:{}.'.format(self.account, e.args))
            return []
Exemple #20
0
 async def get_activate_code(self, session):
     """
     :return:
     """
     try:
         params = {
             'functionId': 'qryCompositeMaterials',
             'body': json.dumps({"qryParam": "[{\"type\":\"advertGroup\",\"id\":\"03744379\","
                                             "\"mapTo\":\"moreActivity\"},{\"type\":\"advertGroup\","
                                             "\"id\":\"04039687\",\"mapTo\":\"atmosphere\"},"
                                             "{\"type\":\"advertGroup\",\"id\":\"04030152\","
                                             "\"mapTo\":\"promotion\"},{\"type\":\"advertGroup\","
                                             "\"id\":\"04395256\",\"mapTo\":\"temporary\"}]",
                                 "activityId": "00360210", "pageId": "666370", "previewTime": "", "reqSrc": ""}),
             'client': 'wh5',
             'clientVersion': '1.0.0',
             'uuid': random_uuid()
         }
         url = 'https://api.m.jd.com/client.action?' + urlencode(params)
         response = await session.post(url=url)
         text = await response.text()
         data = json.loads(text)
         if data.get('code') != '0':
             return None
         item_list = data['data']['moreActivity']['list']
         for item in item_list:
             if '每日抽奖' in item['name']:
                 code = re.search('activityCode=(.*)&', item['link']).group(1)
                 return code
         return None
     except Exception as e:
         println('{}, 获取活动ID失败, {}'.format(self.account, e.args))
         return None
Exemple #21
0
    async def daily_sign(self, session, task):
        """
        每日签到
        :param session:
        :param task:
        :return:
        """

        if task['todayFinishNum'] > 0:
            println('{}, 今日已签到!'.format(self.account))
            return

        sub_node = 'null'

        for item in task['subList']:
            if item['sendStatus'] == 0:
                sub_node = item['node']
                break

        body = {
            "modelId": task['modelId'],
            "taskId": task['taskId'],
            "taskType": task['taskType'],
            "plateCode": 3,
            "subNode": sub_node
        }
        await self.finish_task(session, task['taskName'], body)
 async def run_help(self):
     """
     助力入口
     :return:
     """
     async with aiohttp.ClientSession(headers=self.headers,
                                      cookies=self.cookies) as session:
         item_list = Code.get_code_list(CODE_SMASH_GOLDEN_EGG)
         for item in item_list:
             friend_account, friend_code = item.get('account'), item.get(
                 'code')
             if self.account == friend_account:
                 continue
             body = {
                 "appId": "1EFRQwA",
                 "taskToken": friend_account,
                 "taskId": 6,
                 "actionType": 0
             }
             res = await self.request(session, 'harmony_collectScore', body)
             if res['bizCode'] != 0:
                 println('{}, 助力好友:{}失败, {}'.format(self.account,
                                                    friend_account,
                                                    res.get('bizMsg')))
                 if res['bizCode'] == 105:
                     break
             else:
                 println('{}, 成功助力好友:{}!'.format(self.account,
                                                 friend_account))
             await asyncio.sleep(1)
Exemple #23
0
 async def get_task_list(self, session):
     """
     :param session:
     :return:
     """
     try:
         session.headers.add('Host', 'api.m.jd.com')
         session.headers.add('Content-Type',
                             'application/x-www-form-urlencoded')
         session.headers.add(
             'User-Agent',
             'okhttp/3.12.1;jdmall;android;version/10.0.6;build/88852;screen/1080x2293;os/11'
             ';network/wifi;')
         url = 'https://api.m.jd.com/client.action?functionId=cash_homePage&clientVersion=10.0.6&build=88852&client' \
               '=android&d_brand=realme&d_model=RMX2121&osVersion=11&screen=2293*1080&partner=oppo&oaid=&openudid' \
               '=a27b83d3d1dba1cc&eid=eidA1a01812289s8Duwy8MyjQ9m/iWxzcoZ6Ig7sNGqHp2V8/mtnOs' \
               '+KCpWdqNScNZAsDVpNKfHAj3tMYcbWaPRebvCS4mPPRels2DfOi9PV0J+/ZRhX&sdkVersion=30&lang=zh_CN&uuid' \
               '=a27b83d3d1dba1cc&aid=a27b83d3d1dba1cc&area=19_1601_36953_50397&networkType=wifi&wifiBssid=unknown' \
               '&uts=0f31TVRjBStRmxA4qmf9RVgENWVO2TGQ2MjkiPwRvZZIAsHZydeSHYcTNHWIbLF17jQfBcdAy' \
               '%2BSBzhNlEJweToEyKpbS1Yp0P0AKS78EpxJwB8v%2BZSdypE%2BhFoHHlcMyF4pc0QIWs%2B85gCH%2BHp9' \
               '%2BfP8lKG5QOgoTBOjLn0U5UOXWFvVJlEChArvBygDg6xpmSrzN6AMVHTXrbpV%2FYbl4FQ%3D%3D&uemps=0-0&harmonyOs' \
               '=0&st=1625744661962&sign=c8b023465a9ec1e9b912ac3f00a36377&sv=110&body={}'.format(
             quote(json.dumps({})))
         response = await session.post(url=url)
         text = await response.text()
         data = json.loads(text)
         if data['code'] != 0 or data['data']['bizCode'] != 0:
             return []
         return data['data']['result']['taskInfos']
     except Exception as e:
         println('{}, 获取任务列表失败:{}!'.format(self.account, e.args))
         return []
 async def request(self,
                   session,
                   function_id,
                   body=None,
                   method='POST',
                   callback=None):
     try:
         if body is None:
             body = {}
         url = 'https://api.m.jd.com/client.action?advId={}&functionId={}&body={}&client=wh5&clientVersion=1.0.0&' \
               'uuid=1623732683334633-4613462616133636&appid=o2_act'. \
             format(function_id, function_id, quote(json.dumps(body)))
         if callback:
             url += '&{}'.format(callback)
         if method == 'POST':
             response = await session.post(url=url)
         else:
             response = await session.get(url=url)
         text = await response.text()
         data = json.loads(text)
         if data['code'] != 0:
             return data
         return data['data']
     except Exception as e:
         println('{}, 获取数据失败, {}!'.format(self.account, e.args))
         return {'bizCode': 999, 'bizMsg': '无法获取服务器数据!'}
Exemple #25
0
    async def do_task(self, session, task):
        """
        做任务
        :param session:
        :param task:
        :return:
        """
        url = 'https://api.m.jd.com/client.action?functionId=doTrumpTask&body' \
              '=%7B%22taskId%22%3A{}%2C%22itemId%22%3A%22{}%22%2C%22sign%22%3A2%7D&appid' \
              '=content_ecology&clientVersion=9.2.0' \
              '&client=wh5'.format(task['taskId'], task['taskItemInfo']['itemId'])
        try:
            response = await session.post(url)
            text = await response.text()
            data = json.loads(text)
            if data['code'] != '0':
                logger.info('{}, 做任务失败:{}'.format(self.account, data))
            else:

                println('{}, 完成任务:{}, {}'.format(
                    self.account, task['taskName'],
                    data['result']['lotteryMsg'].replace('\n', '')))

        except Exception as e:
            logger.error('{}, 做任务失败: {}'.format(self.account, e.args))
 async def wish_lottery(self, session, shop_sign="1000014803"):
     """
     心愿抽奖
     """
     data = await self.request(session, 'olympicgames_wishShopLottery',
                               {"shopSign": shop_sign})
     println('{}, 心愿抽奖结果:{}'.format(self.account, data))
Exemple #27
0
    async def lottery(self, session, task_id=None):
        """
        抽奖
        """
        while True:
            body = {"appId": self.appid}

            if task_id:
                body['taskId'] = task_id

            res = await self.request(session,
                                     'interact_template_getLotteryResult',
                                     body)

            if res['bizCode'] != 0:
                println('{}, 抽奖失败, {}!'.format(self.account, res['bizMsg']))
                break
            else:
                award_info = res['result']['userAwardsCacheDto']
                if 'jBeanAwardVo' in award_info:
                    message = award_info['jBeanAwardVo']
                else:
                    message = award_info

                println('{}, 抽奖成功, 获得:{}!'.format(self.account, message))
            await asyncio.sleep(1)
            if task_id:
                break
 async def browser_task_page_view(self, session, task_token):
     """
     访问任务
     """
     try:
         body = {
             "businessId":
             "babel",
             "componentId":
             "1938322209a94fa9945dfae29abe1fc6",
             "taskParam":
             json.dumps({
                 'taskToken': task_token,
                 "biz": "babel",
             })
         }
         url = 'https://api.m.jd.com/?client=wh5&clientVersion=1.0.0' \
               '&functionId=queryVkComponent&body={}&_timestamp={}'.format(quote(json.dumps(body)),
                                                                           int(time.time()) * 1000)
         response = await session.get(url=url)
         text = await response.text()
         data = json.loads(text)
         if data['code'] == '0':
             return True
         else:
             return False
     except Exception as e:
         println('{}, 访问任务页面失败:{}'.format(self.account, e.args))
Exemple #29
0
    async def do_tasks(self, session, task_list):
        """
        做任务
        :param session:
        :param task_list:
        :return:
        """
        for task in task_list:

            task_type, task_name, status = task['taskType'], task[
                'taskName'], task['status']

            if task_type == 14:  # 邀请好友助力
                await self.get_share_code(task)

            if task_type in [3, 27] and task_type == 3:
                await self.lottery(session, task['taskId'])
            if status >= 2:
                println('{}, 任务:《{}》今日已做完!'.format(self.account, task_name))
                continue

            elif task_type in [13, 12]:  # 签到
                task_id = task['taskId']
                task_token = re.search(r"'taskToken': '(.*?)'",
                                       str(task)).group(1)
                await self.finish_task(session, task_id, task_token, task_name)
            elif task_type == 21:  # 入会任务不做
                println('{}, 跳过入会任务!'.format(self.account))
            else:
                await self.browser_task(session, task)
Exemple #30
0
    async def query_task_list(self, session):
        """
        查询任务列表
        :param session:
        :return:
        """
        task_result = []
        body = {
            "riskDeviceInfo": "{}",
            "channelLv": "",
            "environment": "other"
        }
        task_list = []
        data = await self.request(session, 'queryGooseTaskList', body)
        if data['resultCode'] != 0 or data['resultData']['code'] != '0000':
            println('{}, 查询任务列表失败!'.format(self.account))
            return task_list
        task_list = data['resultData']['data']

        for task in task_list:
            if task['status'] == 2:  # 已完成任务跳过
                continue

            if 'doLink' not in task:
                continue

            url = furl(task['doLink'])
            real_time = int(url.args.get('readTime', 0))
            if real_time == 0:  # 非浏览类型任务, 无法完成, 跳过!
                continue
            task['real_time'] = real_time
            task_result.append(task)

        return task_result