python实战===爬取所有微信好友的信息

'''
爬取所有T信好友的信息
'''
import itchat
from pandas import DataFrame

itchat.login()

friends=itchat.get_friends(update=True)[0:]

def get_var(var):
 variable=[]
 for i in friends:
  value=i[var]
  variable.append(value)
 return variable
 

NickName=get_var('NickName')
Sex=get_var('Sex')
Province=get_var('Province')
City=get_var('City')
Signature=get_var('Signature')

data={'NickName':NickName,'Sex':Sex,'Province':Province,'City':City,'Signature':Signature}
frame=DataFrame(data)
frame.to_csv('data.csv',index=True,encoding="utf_8_sig")

 

posted @ 2018-01-29 16:57  AAA五金批发王建军  阅读(1384)  评论(0编辑  收藏  举报