作者 陈俊学

2.2.6

测试添加接口,测试不使用住宅ip
@@ -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: 115  
8 - name: 2.2.5  
  7 + code: 116
  8 + name: 2.2.6
@@ -158,29 +158,29 @@ class FacebookClient(Client): @@ -158,29 +158,29 @@ class FacebookClient(Client):
158 if how_found == 'profile_friends': 158 if how_found == 'profile_friends':
159 data['ref_param'] = 'friends_tab' 159 data['ref_param'] = 'friends_tab'
160 try: 160 try:
161 - session = self._state.session_factory(self.user_obj.user_agent)  
162 - # res = session.get(url, cookies=self._state.get_cookies())  
163 - if how_found == 'profile_button':  
164 - res = self._payload_post("/ajax/add_friend/action.php", data)  
165 - else:  
166 - proxies = {  
167 - "http": "http://8.210.170.163:24000",  
168 - "https": "https://8.210.170.163:24000",  
169 - }  
170 -  
171 - url = "https://www.facebook.com/ajax/add_friend/action?" + self._to_url_params(data)  
172 - res = session.post(url, cookies=self._state.get_cookies(), data=self._state.get_params(),  
173 - proxies=proxies)  
174 - content = _util.check_request(res)  
175 - j = _util.to_json(content)  
176 - # We can't yet, since errors raised in here need to be caught below  
177 - _util.handle_payload_error(j)  
178 - res = j["payload"]  
179 - # 下面是原来的加粉写法 161 + # session = self._state.session_factory(self.user_obj.user_agent)
  162 + # # res = session.get(url, cookies=self._state.get_cookies())
180 # if how_found == 'profile_button': 163 # if how_found == 'profile_button':
181 # res = self._payload_post("/ajax/add_friend/action.php", data) 164 # res = self._payload_post("/ajax/add_friend/action.php", data)
182 # else: 165 # else:
183 - # res = self._payload_post("/ajax/add_friend/action?" + self._to_url_params(data), {}) 166 + # proxies = {
  167 + # "http": "http://8.210.170.163:24000",
  168 + # "https": "https://8.210.170.163:24000",
  169 + # }
  170 + #
  171 + # url = "https://www.facebook.com/ajax/add_friend/action?" + self._to_url_params(data)
  172 + # res = session.post(url, cookies=self._state.get_cookies(), data=self._state.get_params(),
  173 + # proxies=proxies)
  174 + # content = _util.check_request(res)
  175 + # j = _util.to_json(content)
  176 + # # We can't yet, since errors raised in here need to be caught below
  177 + # _util.handle_payload_error(j)
  178 + # res = j["payload"]
  179 + # 下面是原来的加粉写法
  180 + if how_found == 'profile_button':
  181 + res = self._payload_post("/ajax/add_friend/action.php", data)
  182 + else:
  183 + res = self._payload_post("/ajax/add_friend/action?" + self._to_url_params(data), {})
184 except _exception.FBchatNotLoggedIn: 184 except _exception.FBchatNotLoggedIn:
185 raise 185 raise
186 except _exception.FBchatFacebookError as err: 186 except _exception.FBchatFacebookError as err:
@@ -1998,11 +1998,21 @@ class FacebookClient(Client): @@ -1998,11 +1998,21 @@ class FacebookClient(Client):
1998 html_text2 = html_text.replace('<!-- ', '').replace(' -->', '') 1998 html_text2 = html_text.replace('<!-- ', '').replace(' -->', '')
1999 soup = BeautifulSoup(html_text, 'lxml') 1999 soup = BeautifulSoup(html_text, 'lxml')
2000 script = soup.find_all('script') 2000 script = soup.find_all('script')
2001 - de = script[112].prettify()  
2002 - cursor = re.findall(r'{__m:"__elem_559218ec_0_0"},"(.*?)"\]\],\["StarGrid"', de)[0]  
2003 - num_list = re.findall(r'pagelet_timeline_app_collection_(.*?):(.*?):(.*?)"', de)[0]  
2004 - de = script[92].prettify()  
2005 - pagelet_token = re.findall(r'pagelet_token:"(.*?)"', de)[0] 2001 + for key in script:
  2002 + cursor = re.findall(r'{__m:"__elem_559218ec_0_0"},"(.*?)"\]\],\["StarGrid"', key.prettify())
  2003 + if len(cursor):
  2004 + break
  2005 + cursor = cursor[0]
  2006 + for key in script:
  2007 + num_list = re.findall(r'pagelet_timeline_app_collection_(.*?):(.*?):(.*?)"', key.prettify())
  2008 + if len(num_list):
  2009 + break
  2010 + num_list = num_list[0]
  2011 + for key in script:
  2012 + pagelet_token = re.findall(r'pagelet_token:"(.*?)"', key.prettify())
  2013 + if len(pagelet_token):
  2014 + break
  2015 + pagelet_token = pagelet_token[0]
2006 print(cursor, num_list) 2016 print(cursor, num_list)
2007 cache.set(f'{self.email}:AllPhotosAppCollectionPagelet', num_list) 2017 cache.set(f'{self.email}:AllPhotosAppCollectionPagelet', num_list)
2008 cache.set(f'{self.email}:AllPhotosAppCollectionPagelet:pagelet_token', pagelet_token) 2018 cache.set(f'{self.email}:AllPhotosAppCollectionPagelet:pagelet_token', pagelet_token)