# 1、通过群号,获取到群成员信息,下载头像
# 1、请求qq群接口
# 2、获取到每个人的昵称和qq号
# 3、下载图片
import requests,os def get_qq_img(qq_number): url='https://qun.qq.com/cgi-bin/qun_mgr/search_group_members' data={"gc":xxx,"st":0,"end":20,"sort":0,"bkn":xxxxx} header={"cookie":"RK=xxxxK; pgv_pvi=xxxx; tvfe_boss_uuid=xxxxx;" " o_cookie=xxx; pgv_pvid=xxx; " "ptcz=7xxxxxxx81700bbd;" " ts_uid=xxxxxxxx; ts_refer=xui.ptlogin2.qq.com/cgi-bin/xlogin;" " _qpsvr_localtk=xxx4; pgv_si=sxxxxxxxx2; uin=xxxxxxx;" " p_uin=xxxxx; traceid=xxxx582; pgv_info=ssid=xxxx; " "ts_last=qun.qq.com/member.html; skey=xxxxxxxf; " "pt4_token=xxxxxxxxxxxxxxxxxxxfGerFWrJjWRagO0_; " "p_skey=vxxxxxxxxxxxxxxxxxxxxxxethY34pfu9HL8_"} mems=requests.post(url,data, verify=False,headers=header).json().get('mems') img_url = 'https://q4.qlogo.cn/g?b=qq&nk=%s&s=140' #下载图片的接口 if not os.path.exists(str(qq_number)): #文件夹的名字是字符串 os.mkdir(str(qq_number)) d = r'E:xxxxxxxxx\%s'%qq_number for mem in mems: qq = mem.get('uin') # qq nick = mem.get('nick') if not mem.get('card') else mem.get('card') req = requests.get(img_url % qq) path = os.path.join(d, nick) print(path) f = open(path + '.jpg', 'wb') f.write(req.content) f.close() get_qq_img(xxxx)