By group number, the group members to obtain information, download the picture to the specified folder

# 1, by group number, the group members to obtain information, download the picture 
# 1, request qq group interfaces
# 2, to get everyone's nickname and qq number
# 3, download pictures
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' # interface to download the picture
    if not os.path.exists (str (qq_number)): the name of the folder is a string #
        os.mkdir(str(qq_number))

    d = r'E:\xxx\xxx\xxx\%s'%qq_number

    for mem in mems:
        q = mem.get ( 'stuff') # questions
        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)

  

Guess you like

Origin www.cnblogs.com/jiadan/p/11877653.html