💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 安装itchat(假设python3和pip已经装好) ~~~ pip install itchat ~~~ ### 模拟微信登陆 ~~~ import itchat # 模拟登陆 itchat.auto_login(hotReload=True) ~~~ ### 获取微信好友基本信息和位置信息 ~~~ friends = itchat.get_friends(update=True) ~~~ ### 将得到的数据插入到mysql ~~~ import pymysql # 数据库连接 host = "localhost" user = "root" passwd = "root" db = "wechat" charset = "utf8" db = pymysql.connect(host, user, passwd, db, charset) for f in friends: sql = "insert into user(we_name,nick_name,sex,signature,province,city) \ values ('%s','%s','%d','%s','%s','%s')"%(f.UserName,f.NickName,f.Sex,f.Signature,f.Province,f.city) try: cursor.execute(sql) db.commit() except: db.rollback() # 关闭数据库 db.close() ~~~ ### 至此,数据获取完毕! [TOC]