From 85fbe095518031892b02e5e392fbbcbd4b8f19e1 Mon Sep 17 00:00:00 2001 From: chenjunxue <1523825571@qq.com> Date: Fri, 4 Sep 2020 21:02:10 +0800 Subject: [PATCH] 2.3.6 增加登录封锁的详细信息 --- conf/config.yaml | 4 ++-- core/monitor.py | 1 - lib/state.py | 35 ++++++++++++++++++++++++++++++++++- utils/parse_html.py | 19 ++++++++++++++++++- 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index 1b592b8..8a249d1 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -4,5 +4,5 @@ SERVER: reconnect_interval: 3 VERSION: - code: 125 - name: 2.3.5 \ No newline at end of file + code: 126 + name: 2.3.6 \ No newline at end of file diff --git a/core/monitor.py b/core/monitor.py index 3292630..6ccc495 100644 --- a/core/monitor.py +++ b/core/monitor.py @@ -110,7 +110,6 @@ class Monitor(callback.CallBack): # 处理制表符,换行符 email = email.strip().strip('\r\n') password = password.strip().strip('\r\n') - # cookie = cookie.strip().strip('\r\n') limit = 100 if self.size >= limit: raise Exception("单台终端登录到达上限,%d个号" % limit) diff --git a/lib/state.py b/lib/state.py index 2946c1a..7bef98f 100644 --- a/lib/state.py +++ b/lib/state.py @@ -37,6 +37,7 @@ class Session(Session_): content = res.text set_cookie = res.headers.get('Set-Cookie', None) if 'checkpoint' in res.url: + # self.get_deal_lock_method(int(kwargs['data']['jazoest']), kwargs['data']['lsd']) raise FBchatUserError('账号被封锁:' + parse_html.checkpoint_text(content)) elif 'ServerRedirect' in content and self._match_redirect_(content) == '\\/checkpoint\\/block\\/': raise FBchatUserError('账号被封锁') @@ -60,6 +61,39 @@ class Session(Session_): hasattr(self, 'logout_call') and self.logout_call() raise + def get_init_lock_args(self, jazoest: str, lsd: str): + """ + 获取解封方式 所需要参数 + """ + res = super().request('GET', 'https://www.facebook.com/checkpoint/?next') + args = parse_html.get_lock_init(res.text) + fb_dtsg_ag = args[0] + nh = args[1] + params = { + 'modules': 'FormSubmit', + "dpr": 2, + "fb_dtsg_ag": fb_dtsg_ag, + "jazoest": jazoest, + "nh": nh, + "lsd": lsd + } + return params + + def get_deal_lock_method(self, jazoest, lsd): + params = self.get_init_lock_args(jazoest, lsd) + res = super().request('GET', 'https://www.facebook.com/ajax/bootloader-endpoint', + params=params) + + res = super().request('POST', 'https://www.facebook.com/cookie/consent/', + params=params) + + params['submit[Continue]'] = 'Continue' + res = super().request('POST', + 'https://www.facebook.com/checkpoint/async?next' + , data=params + ) + pass + class PCState(State): @@ -128,7 +162,6 @@ class PCState(State): 'lgnjs': int(time.time()), 'timezone': '-480' }) - r = session.post('https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110', data=data) setCookie = r.headers.get('Set-Cookie') or '' diff --git a/utils/parse_html.py b/utils/parse_html.py index d74fd29..a8d90aa 100644 --- a/utils/parse_html.py +++ b/utils/parse_html.py @@ -544,11 +544,28 @@ def get_members_ids(text): def checkpoint_text(text): try: b = bs4.BeautifulSoup(text, 'html.parser') - return b.find('form', class_='checkpoint').find('span').text + c = b.find('form', class_='checkpoint') + for mark in ['span', 'p', 'h3', 'strong']: + content = ''.join([k.text for k in c.find_all(mark)]) + if content: + return content + return "" except: return "" +def get_lock_init(text): + try: + args = list() + result = re.findall(r'{"token":"(.*?)"}', text) + args.append(result[0]) + result = re.findall(r'name="nh" value="(.*?)"', text) + args.append(result[0]) + return args + except: + return '' + + def get_location_info(html): try: selector = etree.HTML(html) -- libgit2 0.24.0