@@ -16,7 +16,7 @@ def __init__(self, qq):
1616 }
1717 self .s = requests .session ()
1818 self .qq_hash = ''
19- self .vfwebqq = ''
19+ self .vf_web_qq = ''
2020 self .user_list_dict = {}
2121 self .group_list_dict = {}
2222 self .PSessionID = ''
@@ -139,7 +139,8 @@ def check_sig(self, url):
139139 response = self .s .get (url , headers = self .header )
140140 # print response.content
141141 # print response.url
142- # print response.cookies # 因302跳转,此处获取不到cookie
142+ print response .cookies # 因302跳转,此处获取不到cookie,如果需要查看cookie,需要设置allow_redirects=False
143+ print response .history
143144 # Set-Cookie:uin=o0875270022; PATH=/; DOMAIN=qq.com;
144145 # Set-Cookie:skey=@uqacxdTvl; PATH=/; DOMAIN=qq.com;
145146 # Set-Cookie:pt2gguin=o0875270022; EXPIRES=Fri, 02-Jan-2020 00:00:00 GMT; PATH=/; DOMAIN=qq.com;
@@ -232,7 +233,7 @@ def get_group_list(self):
232233 获取群组列表信息
233234 """
234235 group_list_url = 'http://s.web2.qq.com/api/get_group_name_list_mask2'
235- group_list_payload = {'r' : json .dumps ({"vfwebqq" : self .vfwebqq , "hash" : self .qq_hash })}
236+ group_list_payload = {'r' : json .dumps ({"vfwebqq" : self .vf_web_qq , "hash" : self .qq_hash })}
236237 self .header ['Host' ] = 's.web2.qq.com'
237238 self .header ['Origin' ] = 'http://s.web2.qq.com'
238239 self .header ['Referer' ] = 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1'
@@ -251,7 +252,7 @@ def get_group_detail(self, group_code):
251252 group_detail_url = 'http://s.web2.qq.com/api/get_group_info_ext2'
252253 group_detail_payload = {
253254 'gcode' : group_code ,
254- 'vfwebqq' : self .vfwebqq ,
255+ 'vfwebqq' : self .vf_web_qq ,
255256 't' : time .time ()
256257 }
257258 self .header ['Host' ] = 's.web2.qq.com'
@@ -265,7 +266,7 @@ def get_friends_info(self):
265266 获取好友信息[原始数据,没有关联]
266267 """
267268 friends_info_url = 'http://s.web2.qq.com/api/get_user_friends2'
268- friends_info_payload = {'r' : json .dumps ({"vfwebqq" : self .vfwebqq , "hash" : self .qq_hash })}
269+ friends_info_payload = {'r' : json .dumps ({"vfwebqq" : self .vf_web_qq , "hash" : self .qq_hash })}
269270 self .header ['Host' ] = 's.web2.qq.com'
270271 self .header ['Origin' ] = 'http://s.web2.qq.com'
271272 self .header ['Referer' ] = 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1'
@@ -343,7 +344,7 @@ def get_friends_qq_by_uin(self, friends_uin):
343344 friends_account_payload = {
344345 'tuin' : friends_uin ,
345346 'type' : 1 ,
346- 'vfwebqq' : self .vfwebqq ,
347+ 'vfwebqq' : self .vf_web_qq ,
347348 't' : time .time (),
348349 }
349350 response = self .s .get (friends_account_url , params = friends_account_payload , headers = self .header )
@@ -458,7 +459,7 @@ def run(self):
458459 self .check_sig (login_status ['check_url' ])
459460 # print self.get_self_info()
460461 # 获取验证令牌
461- self .vfwebqq = self .get_vf_web_qq ()
462+ self .vf_web_qq = self .get_vf_web_qq ()
462463 # 获取hash令牌
463464 self .qq_hash = self .get_hash (self .NAME , self .qq_cookie ['ptwebqq' ])
464465 # 获取SessionId
@@ -537,7 +538,11 @@ def test_send_group_msg():
537538
538539
539540if __name__ == "__main__" :
540- # test_send_friend_msg()
541- test_send_group_msg ()
541+ test_send_friend_msg ()
542+ # test_send_group_msg()
542543
543544
545+ # todo 状态提醒
546+ # {"retcode":0,"result":[{"poll_type":"buddies_status_change","value":{"uin":1166353395,"status":"online","client_type":4}}]}
547+ # {"retcode":0,"result":[{"poll_type":"buddies_status_change","value":{"uin":3019820949,"status":"offline","client_type":1}}]}
548+ # {"retcode":0,"result":[{"poll_type":"buddies_status_change","value":{"uin":3019820949,"status":"online","client_type":21}}]}
0 commit comments