获取微信联系人

 1 import itchat
 2 import pandas as pd
 3 
 4 inchat.auto_login(hotReload=True)
 5 friends=itchat.get_friends(update=True)[0:]
 6 
 7 list=[]
 8 for x in friends[0:]:
    #此处仅加了三个字段,实际远不止这些
9 list.append([x['RemarkName'],x['NickName'],x['Province']]) 10 11 datatable=pd.DataFrame(list) 12 datatable.to_excel("text.xlsx)

抓取微信联系人的脚本

1. 使用微信itchat包

2. 查看包里面姓名,昵称对应的索引值

3. 使用pd.DataFrame()写到excel【在此处花了好久,不知道DataFrame()怎么使用,得到的写入格式都不是自己想要的,最后发现就是一个二维数组格式】

猜你喜欢

转载自www.cnblogs.com/jestin/p/12764372.html