Python生成微信好友信息excel

包括昵称,备注,个性签名等

import itchat ,time,sys,xlwt

file = xlwt.Workbook()
table = file.add_sheet('info', cell_overwrite_ok=True)

itchat.auto_login(hotReload=True)
print(u'logged')
friends = itchat.get_friends(update=True)[0:]

male = female = other = 0

for i in friends[1:]:
    sex = i["Sex"]
    if sex == 1:
        male += 1
    elif sex == 2:
        female += 1
    else:
        other += 1
total = len(friends[1:])

table.write(0, 5, u'[made by Dwyane]')
table.write(0, 7, u'[共'+str(len(friends)-1)+u'位朋友,'+str(male)+u'位男性朋友,'+str(female)+u'位女性朋友,另外'+str(other)+u'位不明性别]')
table.write(0, 0, u'[昵称]')
table.write(0,1,u'[备注名]')
table.write(0,2,u'[省份]')
table.write(0,3,u'[城市]')
table.write(0,4,u'[签名]')

a=0

for i in friends:
    table.write(a+1,0,i['NickName'])
    table.write(a+1,1,i['RemarkName'])
    table.write(a+1,2,i['Province'])
    table.write(a+1,3,i['City'])
    table.write(a+1,4,i['Signature'])
    if i['RemarkName'] == u'':
        table.write(a+1,1,u'[ ]')
    if i['Province'] == u'':
        table.write(a+1,2,u'[ ]')
    if i['City'] == u'':
        table.write(a+1,3,u'[ ]')
    if i['Signature'] == u'':
        table.write(a+1,4,u'[ ]')
    a=a+1
    print(a)

# qm=raw_input("file name >>>:")
aaa='weixin_'+time.strftime("%Y%m%d", time.localtime())+'.xls'
file.save(aaa)
itchat.send('made by Dwyane','filehelper')
itchat.send('@%s@%s' % ('fil',aaa), 'filehelper')
print ("over")

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值