diff --git a/conf/config.yaml b/conf/config.yaml index dac38e3..d585eb1 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -4,5 +4,5 @@ SERVER: reconnect_interval: 3 VERSION: - code: 111 - name: 2.2.1 \ No newline at end of file + code: 112 + name: 2.2.2 \ No newline at end of file diff --git a/core/monitor.py b/core/monitor.py index e21bc58..b421ff9 100644 --- a/core/monitor.py +++ b/core/monitor.py @@ -116,7 +116,7 @@ class Monitor(callback.CallBack): return client.info() else: if user_agent is None or user_agent == '': - w + user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36' obj = self.onLoggingIn(email, password, cookie, user_agent, proxy) try: client = FacebookClient(obj, logout_call=functools.partial(self.logout, obj.email), diff --git a/lib/facebook.py b/lib/facebook.py index 7b26daa..28c3990 100644 --- a/lib/facebook.py +++ b/lib/facebook.py @@ -1278,8 +1278,8 @@ class FacebookClient(Client): msg = parse_html.get_div_text(res['actions'][0]['html']) else: msg = '操作成功' - except: - msg = '操作失败' + except Exception as err: + msg = f'操作失败:{err}' return msg def sendMoment(self, text, type="TEXT", privacy='EVERYONE', location=None, attachments=None, with_tags_ids=None): diff --git a/lib/state.py b/lib/state.py index 69cdbde..2946c1a 100644 --- a/lib/state.py +++ b/lib/state.py @@ -76,7 +76,7 @@ class PCState(State): session = Session() header = '''accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 - accept-language: zh-CN,zh;q=0.9 + accept-language: en-US,en;q=0.5 cache-control: no-cache pragma: no-cache sec-fetch-dest: document @@ -85,7 +85,7 @@ class PCState(State): sec-fetch-user: ?1 upgrade-insecure-requests: 1 user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 - viewport-width: 1440''' + viewport-width: 1920''' session.headers.update({k: v for k, v in [h.strip().split(': ', maxsplit=1) for h in header.split('\n') if h]}) session.headers["User-Agent"] = user_agent or cls.random_useragent() if is_mobile(session.headers["User-Agent"]): diff --git a/utils/parse_html.py b/utils/parse_html.py index f3d6685..30bebe2 100644 --- a/utils/parse_html.py +++ b/utils/parse_html.py @@ -6,7 +6,9 @@ # @Software: PyCharm import base64 import json +import random import re +import string import time from urllib import parse @@ -40,9 +42,9 @@ def friend_unit(p: dict): unit = li.find('div', class_='friendBrowserUnit') thread_id = unit.find('input', class_='friendBrowserID').attrs['value'] try: - img_attrs=li.find('img').attrs - title=img_attrs['aria-label'] - src=img_attrs['src'] + img_attrs = li.find('img').attrs + title = img_attrs['aria-label'] + src = img_attrs['src'] result.append({'fbid': thread_id, 'name': title, 'src': src}) except: result.append({'fbid': thread_id, 'name': None, 'src': None}) @@ -80,6 +82,17 @@ def find_input_fields_with_pc(html): return login_form.find_all("input") +def find_hsi_with_pc(html): + b = bs4.BeautifulSoup(html, "html.parser") + a = b.select('script')[4] + xw_dict = { + 'hsi': re.findall(r',"hsi":"(.*?)",', a.text)[0], + 'pkg_cohort': re.findall(r',"pkg_cohort":"(.*?)",', a.text)[0], + 'server_revision': re.findall(r',{"server_revision":(.*?),"client_revision', a.text)[0] + } + return xw_dict + + def get_publickey_id(text): try: pub = re.findall(r'"pubKey":({.*?})', text)[0] @@ -109,6 +122,10 @@ def get_domops_3(res): return html +def get_webSessionId(): + return ':'.join([''.join(random.sample(string.ascii_lowercase + string.digits, 6)) for _ in range(3)]) + + def get_overview_text(res): html = get_domops_3(res) msgs = [] @@ -208,6 +225,7 @@ def get_all_unit_id(text): pass return result + def get_hidden_input(res): text = get_domops_3(res) b = bs4.BeautifulSoup(text, 'html.parser')