作者 陈俊学

2.3.6

增加登录封锁的详细信息
@@ -4,5 +4,5 @@ SERVER: @@ -4,5 +4,5 @@ SERVER:
4 reconnect_interval: 3 4 reconnect_interval: 3
5 5
6 VERSION: 6 VERSION:
7 - code: 125  
8 - name: 2.3.5  
  7 + code: 126
  8 + name: 2.3.6
@@ -110,7 +110,6 @@ class Monitor(callback.CallBack): @@ -110,7 +110,6 @@ class Monitor(callback.CallBack):
110 # 处理制表符,换行符 110 # 处理制表符,换行符
111 email = email.strip().strip('\r\n') 111 email = email.strip().strip('\r\n')
112 password = password.strip().strip('\r\n') 112 password = password.strip().strip('\r\n')
113 - # cookie = cookie.strip().strip('\r\n')  
114 limit = 100 113 limit = 100
115 if self.size >= limit: 114 if self.size >= limit:
116 raise Exception("单台终端登录到达上限,%d个号" % limit) 115 raise Exception("单台终端登录到达上限,%d个号" % limit)
@@ -37,6 +37,7 @@ class Session(Session_): @@ -37,6 +37,7 @@ class Session(Session_):
37 content = res.text 37 content = res.text
38 set_cookie = res.headers.get('Set-Cookie', None) 38 set_cookie = res.headers.get('Set-Cookie', None)
39 if 'checkpoint' in res.url: 39 if 'checkpoint' in res.url:
  40 + # self.get_deal_lock_method(int(kwargs['data']['jazoest']), kwargs['data']['lsd'])
40 raise FBchatUserError('账号被封锁:' + parse_html.checkpoint_text(content)) 41 raise FBchatUserError('账号被封锁:' + parse_html.checkpoint_text(content))
41 elif 'ServerRedirect' in content and self._match_redirect_(content) == '\\/checkpoint\\/block\\/': 42 elif 'ServerRedirect' in content and self._match_redirect_(content) == '\\/checkpoint\\/block\\/':
42 raise FBchatUserError('账号被封锁') 43 raise FBchatUserError('账号被封锁')
@@ -60,6 +61,39 @@ class Session(Session_): @@ -60,6 +61,39 @@ class Session(Session_):
60 hasattr(self, 'logout_call') and self.logout_call() 61 hasattr(self, 'logout_call') and self.logout_call()
61 raise 62 raise
62 63
  64 + def get_init_lock_args(self, jazoest: str, lsd: str):
  65 + """
  66 + 获取解封方式 所需要参数
  67 + """
  68 + res = super().request('GET', 'https://www.facebook.com/checkpoint/?next')
  69 + args = parse_html.get_lock_init(res.text)
  70 + fb_dtsg_ag = args[0]
  71 + nh = args[1]
  72 + params = {
  73 + 'modules': 'FormSubmit',
  74 + "dpr": 2,
  75 + "fb_dtsg_ag": fb_dtsg_ag,
  76 + "jazoest": jazoest,
  77 + "nh": nh,
  78 + "lsd": lsd
  79 + }
  80 + return params
  81 +
  82 + def get_deal_lock_method(self, jazoest, lsd):
  83 + params = self.get_init_lock_args(jazoest, lsd)
  84 + res = super().request('GET', 'https://www.facebook.com/ajax/bootloader-endpoint',
  85 + params=params)
  86 +
  87 + res = super().request('POST', 'https://www.facebook.com/cookie/consent/',
  88 + params=params)
  89 +
  90 + params['submit[Continue]'] = 'Continue'
  91 + res = super().request('POST',
  92 + 'https://www.facebook.com/checkpoint/async?next'
  93 + , data=params
  94 + )
  95 + pass
  96 +
63 97
64 class PCState(State): 98 class PCState(State):
65 99
@@ -128,7 +162,6 @@ class PCState(State): @@ -128,7 +162,6 @@ class PCState(State):
128 'lgnjs': int(time.time()), 162 'lgnjs': int(time.time()),
129 'timezone': '-480' 163 'timezone': '-480'
130 }) 164 })
131 -  
132 r = session.post('https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110', 165 r = session.post('https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110',
133 data=data) 166 data=data)
134 setCookie = r.headers.get('Set-Cookie') or '' 167 setCookie = r.headers.get('Set-Cookie') or ''
@@ -544,11 +544,28 @@ def get_members_ids(text): @@ -544,11 +544,28 @@ def get_members_ids(text):
544 def checkpoint_text(text): 544 def checkpoint_text(text):
545 try: 545 try:
546 b = bs4.BeautifulSoup(text, 'html.parser') 546 b = bs4.BeautifulSoup(text, 'html.parser')
547 - return b.find('form', class_='checkpoint').find('span').text 547 + c = b.find('form', class_='checkpoint')
  548 + for mark in ['span', 'p', 'h3', 'strong']:
  549 + content = ''.join([k.text for k in c.find_all(mark)])
  550 + if content:
  551 + return content
  552 + return ""
548 except: 553 except:
549 return "" 554 return ""
550 555
551 556
  557 +def get_lock_init(text):
  558 + try:
  559 + args = list()
  560 + result = re.findall(r'{"token":"(.*?)"}', text)
  561 + args.append(result[0])
  562 + result = re.findall(r'name="nh" value="(.*?)"', text)
  563 + args.append(result[0])
  564 + return args
  565 + except:
  566 + return ''
  567 +
  568 +
552 def get_location_info(html): 569 def get_location_info(html):
553 try: 570 try:
554 selector = etree.HTML(html) 571 selector = etree.HTML(html)