作者 lemon

增加好友的好友的获取接口

@@ -49,7 +49,6 @@ def message_receive(message): @@ -49,7 +49,6 @@ def message_receive(message):
49 monitor.execute(cmd) 49 monitor.execute(cmd)
50 elif type_ == 'initialize': 50 elif type_ == 'initialize':
51 monitor.init_config = json.loads(data_) 51 monitor.init_config = json.loads(data_)
52 -  
53 except: 52 except:
54 import traceback 53 import traceback
55 print(traceback.format_exc()) 54 print(traceback.format_exc())
@@ -836,7 +836,7 @@ class FacebookClient(Client): @@ -836,7 +836,7 @@ class FacebookClient(Client):
836 'ext_data': ext_data, 836 'ext_data': ext_data,
837 } 837 }
838 838
839 - def friendsList(self, ext_data=None): 839 + def friendsList(self, ext_data=None, fbid=None):
840 if ext_data: 840 if ext_data:
841 ext_data = common.frombase64(ext_data) 841 ext_data = common.frombase64(ext_data)
842 842
@@ -868,8 +868,15 @@ class FacebookClient(Client): @@ -868,8 +868,15 @@ class FacebookClient(Client):
868 res = res['data']['node'] 868 res = res['data']['node']
869 869
870 else: 870 else:
871 - res = self._state._session.get(self._state.page_url.replace('profile.php?id=', '') + '/friends')  
872 - if res.status_code == 200 and '/friends' in res.url: 871 +
  872 + if fbid:
  873 + # url = f'https://www.facebook.com/{fbid}/friends'
  874 + url = f'https://www.facebook.com/profile.php?id={fbid}&sk=friends'
  875 + else:
  876 + url = self._state.page_url.replace('profile.php?id=', '') + '/friends'
  877 +
  878 + res = self._state._session.get(url)
  879 + if res.status_code == 200 and 'friends' in res.url:
873 res = parse_html.get_friend_div(res.text) 880 res = parse_html.get_friend_div(res.text)
874 if not res: 881 if not res:
875 respone = { 882 respone = {
@@ -52,7 +52,7 @@ class Do(): @@ -52,7 +52,7 @@ class Do():
52 def three(self, x, y, z): 52 def three(self, x, y, z):
53 print(locals()) 53 print(locals())
54 54
55 - def createGroup(self,message,user_ids): 55 + def createGroup(self, message, user_ids):
56 print(locals()) 56 print(locals())
57 57
58 58
@@ -65,7 +65,7 @@ if __name__ == '__main__': @@ -65,7 +65,7 @@ if __name__ == '__main__':
65 f1 = join(d.two, {"x": 'x1', "y": 'y2', 'z': 'z3'}) 65 f1 = join(d.two, {"x": 'x1', "y": 'y2', 'z': 'z3'})
66 f2 = join(d.one, 'x2') 66 f2 = join(d.one, 'x2')
67 67
68 - f3 = join(d.createGroup,{"message":"12333","user_ids":[1,2,3,4,5]}) 68 + f3 = join(d.createGroup, {"message": "12333", "user_ids": [1, 2, 3, 4, 5]})
69 69
70 t.submit(**f1) 70 t.submit(**f1)
71 t.submit(**f2) 71 t.submit(**f2)
@@ -189,9 +189,9 @@ def get_div_text(html): @@ -189,9 +189,9 @@ def get_div_text(html):
189 189
190 190
191 def get_friend_div(text): 191 def get_friend_div(text):
192 - if 'ProfileCometAppSectionFriendsList' in text: 192 + if 'TimelineAppCollectionListRenderer' in text:
193 b = bs4.BeautifulSoup(text, 'html.parser') 193 b = bs4.BeautifulSoup(text, 'html.parser')
194 - script = b.find('script', string=re.compile(r'ProfileCometAppSectionFriendsList')) 194 + script = b.find('script', string=re.compile(r'TimelineAppCollectionListRenderer'))
195 a = re.findall(r'TimelineAppCollectionListRenderer",collection:(\{.*?\}\}\})', script.string)[0] 195 a = re.findall(r'TimelineAppCollectionListRenderer",collection:(\{.*?\}\}\})', script.string)[0]
196 res = demjson.decode(a) 196 res = demjson.decode(a)
197 return res 197 return res