瞎玩微信(再进一步)


import itchat
import xlwt

#t = str.maketrans('','','\'')
dx = {"Uin": 0,"UserName":'',"NickName":'',"HeadImgUrl":'',"ContactFlag":'',"MemberCount":'',"MemberList":'',"RemarkName":'',"HideInputBarFlag":0,"Sex":0,"Signature":'',"VerifyFlag": 0,"OwnerUin": 0,"StarFriend":0,"AppAccountFlag": 0,"Statues": 0,"AttrStatus": 119911,"Province":'',"City":'',"Alias":'', "SnsFlag":0,"UniFriend": 0,"DisplayName":"","ChatRoomId": 0,"KeyWord":'',"EncryChatRoomId":''}
FriendList = []
keys = []
sALL = ' '

def ADDdict(keys):
    jian = keys[0].replace('\'','')
    #print(jian)
    zhi = keys[1].replace('\'','')
    #print(zhi)
    if jian in dx:
        return True
    else:
        return False

def EDITstr(strs):
    x = []
    a = ''
    a = strs.replace(' ','')
    #strs = a.replace('<','《')
    #a = strs.replace('>','》')
    for i in range(len(a)):
        x.append(a[i])
    for i in range(len(x)):
        if i > 0 and x[i] == ',':
            if not(x[i-1] == '\'' or x[i+1] == '\''):
                print(str(i) + '   ' + x[i])
                x[i] = ' & '
    a = ''.join(x)
    return a

def GetData(fd):
    name = []
    user = str(fd)
    user = user[9:-3]
    Auser = user.split("}>, <User: {")
    print(len(Auser))
    for i in range(len(Auser)):
        sALL = EDITstr(Auser[i])
        dic = sALL.split(",")
        di = {}
        for ii in range(len(dic)):
            keys = dic[ii].split(":")
            if ADDdict(keys):
                di[keys[0]] = keys[1]
        
        name.append(di)
        print(len(Auser))        
    return name   

def sendmsgs(datas):
    d = {}
    for r in range(0,len(datas)):
        d = datas[r]
        itchat.send("لُلُصّبُلُلُصّبُرً رً",d["UserName"])
        print(r)
        time.sleep(5)

def DataSave(datas):
    wb = xlwt.Workbook(encoding='utf8')
    ws = wb.add_sheet('sheet1')
    y = 0
    lists = []
    for i in datas[0].keys():
        ws.write(0,y,i)
        lists.append(i)
        y += 1
    y = 0
    try:
        for r in range(0,len(datas)):
            d = {}
            cells = ""
            for c in range(len(datas[0])):
                d = datas[r]
                cells = lists[c]
                ws.write(r+1,c,d[cells])
                y += 1
            y = 0
        wb.save('FriendWY.xls')
    except:
        print("程序错误,文件信息未能写入。")

#main()
itchat.auto_login()
fd = itchat.get_friends(update=True)
FriendList = GetData(fd)
DataSave(FriendList)

运行吧!玩玩看。很懒惰地把储存文件放在原地了。加了一点点隐藏的小福利,不讲解了会用的自然会。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值