diff --git a/core/core.py b/core/core.py index 4810e17..47a7da9 100644 --- a/core/core.py +++ b/core/core.py @@ -49,7 +49,6 @@ def message_receive(message): monitor.execute(cmd) elif type_ == 'initialize': monitor.init_config = json.loads(data_) - except: import traceback print(traceback.format_exc()) diff --git a/lib/facebook.py b/lib/facebook.py index 1548a61..bf02b0c 100644 --- a/lib/facebook.py +++ b/lib/facebook.py @@ -836,7 +836,7 @@ class FacebookClient(Client): 'ext_data': ext_data, } - def friendsList(self, ext_data=None): + def friendsList(self, ext_data=None, fbid=None): if ext_data: ext_data = common.frombase64(ext_data) @@ -868,8 +868,15 @@ class FacebookClient(Client): res = res['data']['node'] else: - res = self._state._session.get(self._state.page_url.replace('profile.php?id=', '') + '/friends') - if res.status_code == 200 and '/friends' in res.url: + + if fbid: + # url = f'https://www.facebook.com/{fbid}/friends' + url = f'https://www.facebook.com/profile.php?id={fbid}&sk=friends' + else: + url = self._state.page_url.replace('profile.php?id=', '') + '/friends' + + res = self._state._session.get(url) + if res.status_code == 200 and 'friends' in res.url: res = parse_html.get_friend_div(res.text) if not res: respone = { diff --git a/utils/parameter.py b/utils/parameter.py index 9630836..74d1b21 100644 --- a/utils/parameter.py +++ b/utils/parameter.py @@ -52,7 +52,7 @@ class Do(): def three(self, x, y, z): print(locals()) - def createGroup(self,message,user_ids): + def createGroup(self, message, user_ids): print(locals()) @@ -65,7 +65,7 @@ if __name__ == '__main__': f1 = join(d.two, {"x": 'x1', "y": 'y2', 'z': 'z3'}) f2 = join(d.one, 'x2') - f3 = join(d.createGroup,{"message":"12333","user_ids":[1,2,3,4,5]}) + f3 = join(d.createGroup, {"message": "12333", "user_ids": [1, 2, 3, 4, 5]}) t.submit(**f1) t.submit(**f2) diff --git a/utils/parse_html.py b/utils/parse_html.py index af6e8cb..033f5fc 100644 --- a/utils/parse_html.py +++ b/utils/parse_html.py @@ -189,9 +189,9 @@ def get_div_text(html): def get_friend_div(text): - if 'ProfileCometAppSectionFriendsList' in text: + if 'TimelineAppCollectionListRenderer' in text: b = bs4.BeautifulSoup(text, 'html.parser') - script = b.find('script', string=re.compile(r'ProfileCometAppSectionFriendsList')) + script = b.find('script', string=re.compile(r'TimelineAppCollectionListRenderer')) a = re.findall(r'TimelineAppCollectionListRenderer",collection:(\{.*?\}\}\})', script.string)[0] res = demjson.decode(a) return res