From da079a3b7b8b4a438da8ac6e3351a9d3caf23040 Mon Sep 17 00:00:00 2001 From: songjiang Date: Thu, 27 Jun 2019 14:11:56 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=AE=8C=E6=AF=95=E7=9A=84=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 4 ++-- requirements.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index a7d3111..44f64fd 100644 --- a/app/main.py +++ b/app/main.py @@ -1,5 +1,6 @@ import logging import os +import datetime import pickle import traceback from pathlib import Path @@ -27,8 +28,7 @@ def main(): if not job.job_success: jobs_failed.append(job.job_name) - - print('=================================') + print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M')+'=================') print('= 任务数: {}; 失败数: {}'.format(len(jobs), len(jobs_failed))) if jobs_failed: diff --git a/requirements.txt b/requirements.txt index 1eb6b10..7c68053 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ PyQt5==5.10.1 pyquery requests +datetime From 5c401f16d5c2ffda7dcd053c929f9027e4d7897e Mon Sep 17 00:00:00 2001 From: songjiang Date: Thu, 27 Jun 2019 14:13:21 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=86=85=E7=BD=AE=E5=BA=93=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=8A=A0=E5=85=A5requre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7c68053..1eb6b10 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ PyQt5==5.10.1 pyquery requests -datetime From 37ae595b464dacec3b877fcb233bf0eeb1e0a915 Mon Sep 17 00:00:00 2001 From: songjiang Date: Thu, 27 Jun 2019 16:58:32 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=8F=8C=E7=AD=BE=E5=BE=85=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/job/double_sign.py | 63 ++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/app/job/double_sign.py b/app/job/double_sign.py index 418e521..ee1868a 100644 --- a/app/job/double_sign.py +++ b/app/job/double_sign.py @@ -1,4 +1,5 @@ import traceback +import time from pyquery import PyQuery @@ -10,7 +11,9 @@ class DoubleSign(Daka): job_name = '双签赢奖励' index_url = 'https://ljd.m.jd.com/countersign/index.action' - sign_url = 'https://ljd.m.jd.com/countersign/receiveAward.json' + print((int)(time.time())) + sign_url = 'https://ms.jr.jd.com/gw/generic/jrm/h5/m/getAwardList?_=' + \ + str((int)(time.time())) test_url = index_url def is_signed(self): @@ -37,43 +40,29 @@ def sign(self): jd_signed = document('#jdHasSign').val() == 'true' jr_signed = document('#jrHasSign').val() == 'true' - if not (jd_signed and jr_signed): - sign_success = False - message = '完成双签才可领取礼包' + # if not (jd_signed and jr_signed): + # sign_success = False + # message = '完成双签才可领取礼包' - else: - try: - res = self.do_sign() - except RequestError as e: - self.logger.error('双签失败: {}'.format(e.message)) - return False - - if res['code'] == '0': - award_data = res.get('data') + # else: + try: + res = self.do_sign() + except RequestError as e: + self.logger.error('双签失败: {}'.format(e.message)) + return False - if not award_data: - message = '运气不佳,领到一个空空的礼包' + if res['resultCode'] == 200: + award_data = res.get('awardList') - else: - award = award_data[0] - sign_success = True - message = '领到 {} 个{}'.format(award['awardCount'], award['awardName']) + if not award_data: + message = '运气不佳,领到一个空空的礼包' else: - # 活动不定时开启,将活动时间未开始/已结束等情况都视作签到成功 - - if res['code'] == 'DS102': - message = '来早了,活动还未开始' - elif res['code'] == 'DS103': - message = '来晚了,活动已经结束了' - elif res['code'] == 'DS104': - message = '运气不佳,领到一个空空的礼包' - elif res['code'] == 'DS106': - sign_success = False - message = '完成双签才可领取礼包' - else: - sign_success = False - message = '未知错误,Code={}'.format(res['code']) + award = award_data[0] + sign_success = True + message = '领到 {} 个{}'.format( + award['count'], award['name']) + self.logger.info('双签成功: {}; Message: {}'.format(sign_success, message)) @@ -84,12 +73,14 @@ def do_sign(self): try: as_json = r.json() + # print(as_json) except ValueError: - raise RequestError('unexpected response: url: {}; http code: {}'.format(self.sign_url, r.status_code), response=r) + raise RequestError('unexpected response: url: {}; http code: {}'.format( + self.sign_url, r.status_code), response=r) - if 'res' in as_json and 'code' in as_json['res']: + if 'resultData' in as_json and 'resultCode' in as_json['resultData']: # 请求成功 - return as_json['res'] + return as_json['resultData'] else: error_msg = as_json.get('message') or str(as_json) From ce6f8a57d5eaa29fe278202970f2238e0488b414 Mon Sep 17 00:00:00 2001 From: songjiang Date: Thu, 27 Jun 2019 17:24:34 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=8F=8C=E7=AD=BE=20OK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/job/double_sign.py | 69 ++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/app/job/double_sign.py b/app/job/double_sign.py index ee1868a..7a14f82 100644 --- a/app/job/double_sign.py +++ b/app/job/double_sign.py @@ -11,62 +11,53 @@ class DoubleSign(Daka): job_name = '双签赢奖励' index_url = 'https://ljd.m.jd.com/countersign/index.action' - print((int)(time.time())) sign_url = 'https://ms.jr.jd.com/gw/generic/jrm/h5/m/getAwardList?_=' + \ str((int)(time.time())) test_url = index_url - def is_signed(self): - signed = False - - try: - signed = PyQuery(self.page_data())('#awardFlag').val() == '2' - self.logger.info('今日已双签: {}'.format(signed)) - - except Exception as e: - self.logger.error('返回数据结构可能有变化, 获取双签数据失败: {}'.format(e)) - traceback.print_exc() - - return signed - def sign(self): # 参见 https://ljd.m.jd.com/js/countersign/countersign.js sign_success = True message = '' - document = PyQuery(self.page_data()) - - jd_signed = document('#jdHasSign').val() == 'true' - jr_signed = document('#jrHasSign').val() == 'true' + if(self.check()): + try: + res = self.do_sign() + except RequestError as e: + self.logger.error('双签失败: {}'.format(e.message)) + return False - # if not (jd_signed and jr_signed): - # sign_success = False - # message = '完成双签才可领取礼包' + if res['resultCode'] == 200: + award_data = res.get('awardList') - # else: - try: - res = self.do_sign() - except RequestError as e: - self.logger.error('双签失败: {}'.format(e.message)) - return False - - if res['resultCode'] == 200: - award_data = res.get('awardList') + if not award_data: + message = '运气不佳,领到一个空空的礼包' - if not award_data: - message = '运气不佳,领到一个空空的礼包' - - else: - award = award_data[0] - sign_success = True - message = '领到 {} 个{}'.format( - award['count'], award['name']) - + else: + award = award_data[0] + sign_success = True + message = '领到 {} 个{}'.format( + award['count'], award['name']) + else: + sign_success = False + message = '完成双签才可领取礼包' self.logger.info('双签成功: {}; Message: {}'.format(sign_success, message)) return sign_success + # 完成双签才可访问 + def is_signed(self): + checkUrl = 'https://ms.jr.jd.com/gw/generic/jrm/h5/m/signInit?_=' + \ + str((int)(time.time())) + r = self.session.post(checkUrl) + as_json = r.json() + # as_json = {'resultCode': 0, 'resultMsg': '操作成功', 'resultData': {'isGet': True, 'isSignInJr': True, 'isSignInJd': True,'resultCode': 200, 'isNewUser': {'resultCode': 200, 'amount': 500, 'isNewUser': 'no', 'resultMsg': '响应成功'}, 'resultMsg': '响应成功', 'longDaySign': True}, 'channelEncrypt': 0} + if 'resultData' in as_json and 'resultCode' in as_json['resultData'] and as_json['resultData']['resultCode'] == 200: + # 请求成功 + return as_json['resultData']['isSignInJr'] and as_json['resultData']['isSignInJd'] + + return False def do_sign(self): r = self.session.post(self.sign_url) From 46d63bbfc880f4349b9b716165670134fe0e8c90 Mon Sep 17 00:00:00 2001 From: songjiang Date: Mon, 15 Jul 2019 14:15:17 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8F=8C=E7=AD=BE=E5=A5=96=E5=8A=B1=20ok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/job/double_sign.py | 44 ++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/app/job/double_sign.py b/app/job/double_sign.py index 7a14f82..fbf6459 100644 --- a/app/job/double_sign.py +++ b/app/job/double_sign.py @@ -10,20 +10,19 @@ class DoubleSign(Daka): job_name = '双签赢奖励' - index_url = 'https://ljd.m.jd.com/countersign/index.action' - sign_url = 'https://ms.jr.jd.com/gw/generic/jrm/h5/m/getAwardList?_=' + \ + index_url = 'https://ms.jr.jd.com/gw/generic/jrm/h5/m/getAwardList?_=' + \ + str((int)(time.time())) + sign_url = 'https://ms.jr.jd.com/gw/generic/jrm/h5/m/getSignAwardJR?_=' +\ str((int)(time.time())) test_url = index_url def sign(self): - # 参见 https://ljd.m.jd.com/js/countersign/countersign.js - sign_success = True message = '' - - if(self.check()): + if(self.is_signed()): try: res = self.do_sign() + print(res) except RequestError as e: self.logger.error('双签失败: {}'.format(e.message)) return False @@ -46,25 +45,30 @@ def sign(self): self.logger.info('双签成功: {}; Message: {}'.format(sign_success, message)) return sign_success - # 完成双签才可访问 - def is_signed(self): - checkUrl = 'https://ms.jr.jd.com/gw/generic/jrm/h5/m/signInit?_=' + \ - str((int)(time.time())) - r = self.session.post(checkUrl) - as_json = r.json() - # as_json = {'resultCode': 0, 'resultMsg': '操作成功', 'resultData': {'isGet': True, 'isSignInJr': True, 'isSignInJd': True,'resultCode': 200, 'isNewUser': {'resultCode': 200, 'amount': 500, 'isNewUser': 'no', 'resultMsg': '响应成功'}, 'resultMsg': '响应成功', 'longDaySign': True}, 'channelEncrypt': 0} - if 'resultData' in as_json and 'resultCode' in as_json['resultData'] and as_json['resultData']['resultCode'] == 200: - # 请求成功 - return as_json['resultData']['isSignInJr'] and as_json['resultData']['isSignInJd'] + def is_signed(self): return False + sign = False + r = self.session.post(self.index_url) + as_json = r.json() + if 'resultData' in as_json and 'awardList' in as_json['resultData']: + award_data = as_json['resultData'].get('awardList') + sign = True + self.logger.info('今日已签到: {}; 双签奖励: {}'.format(sign, award_data[0]['count'])) + return sign + return sign def do_sign(self): r = self.session.post(self.sign_url) try: as_json = r.json() - # print(as_json) + #{'resultCode': 0, 'resultMsg': '操作成功', + # 'resultData': {'resultCode': 200, ' + # resultMsg': '响应成功', + # 'status': 0, 'awardList': [ + # {'count': 5, 'name': '京豆', 'type': 1}]}, + # 'channelEncrypt': 0} except ValueError: raise RequestError('unexpected response: url: {}; http code: {}'.format( self.sign_url, r.status_code), response=r) @@ -77,9 +81,3 @@ def do_sign(self): error_msg = as_json.get('message') or str(as_json) error_code = as_json.get('businessCode') or as_json.get('code') raise RequestError(error_msg, error_code) - - def page_data(self): - if not hasattr(self, '_page_data'): - self._page_data = self.session.get(self.index_url).text - - return self._page_data From 5ed1f8317f32d2e2f31a870018a8179559c12368 Mon Sep 17 00:00:00 2001 From: songjiang Date: Tue, 16 Jul 2019 11:41:35 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=8F=8C=E7=AD=BE=E7=BB=86=E8=8A=82?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/job/double_sign.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/job/double_sign.py b/app/job/double_sign.py index fbf6459..afa3c0d 100644 --- a/app/job/double_sign.py +++ b/app/job/double_sign.py @@ -19,10 +19,9 @@ class DoubleSign(Daka): def sign(self): sign_success = True message = '' - if(self.is_signed()): + if(self.is_signed() == False): try: res = self.do_sign() - print(res) except RequestError as e: self.logger.error('双签失败: {}'.format(e.message)) return False @@ -47,25 +46,25 @@ def sign(self): return sign_success def is_signed(self): - return False sign = False r = self.session.post(self.index_url) as_json = r.json() if 'resultData' in as_json and 'awardList' in as_json['resultData']: award_data = as_json['resultData'].get('awardList') sign = True - self.logger.info('今日已签到: {}; 双签奖励: {}'.format(sign, award_data[0]['count'])) + self.logger.info('今日已签到: {}; 双签奖励: {}'.format( + sign, award_data[0]['count'])) return sign - return sign + return False def do_sign(self): r = self.session.post(self.sign_url) try: as_json = r.json() - #{'resultCode': 0, 'resultMsg': '操作成功', + # {'resultCode': 0, 'resultMsg': '操作成功', # 'resultData': {'resultCode': 200, ' - # resultMsg': '响应成功', + # resultMsg': '响应成功', # 'status': 0, 'awardList': [ # {'count': 5, 'name': '京豆', 'type': 1}]}, # 'channelEncrypt': 0}