这篇文章将为大家详细讲解有关怎么用python wxpy管理微信公众号并利用微信获取自己的开源数据,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
python主要应用领域有哪些
1,云计算,典型应用OpenStack.2,网前端开发,众多大型网站均为python开发。3。人工智能应用,基于大数据分析和深度学习而发展出来的人工智能本质上已经无法离开python.4,系统运维工程项目,自动化运维的标配就是python + Django/flask.5,金融理财分析,量化交易,金融分析。6,大数据分析。
首先wxpy是itchat的升级版,通过wxpy bot.core即可原封不动的调用itchat的指令。
<强>可以实现的简单功能:强>
1。调取所有微信好友的信息,包括头像,签的名,地区,等信息。
#, - *安康;编码:utf-8 - * - “““ Created 提醒Fri Jul 19 17:10:01 2019 , @author: wenzhe.tian “““ import wxpy  as wp 得到collections import  defaultdict import pandas  as pd 得到tkinter import 对话框 import 操作系统 #初始化机器人,选择缓存模式(扫码)登录 时间=bot wp.Bot (cache_path=True) 时间=friend bot.core.get_friends(更新=True) (0:) num =0 for f 拷贝的朋友:=,,image  bot.core.get_head_img(用户名=f [“UserName"]), #用,itchat.get_head_img(用户名=None)来爬取好友列表的头像=,fileImage 开放(str (num), +,“.jpg", & # 39; wb # 39;), #将好友头像下载到本地 ,fileImage.write(图片) ,fileImage.close () num +=, 1 朋友=pd.DataFrame(朋友), friend.to_excel (& # 39; friend.xlsx& # 39;, sheet_name=& # 39; Friend_Info& # 39;) #所有朋友相关资料存为excel
根据上面可以做一些头像集合,或者微信好友的动态图表统计。
2只;消息回复
bot.friends () .search(& # 39;老九门里排第十& # 39;)[0].send(& # 39;(强)& # 39;),#表示回复给,& # 39;老九门里排第十& # 39;,点赞符号,相当于,friends.search ()
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
然而这些不能满足一些高级的需求比如:
1。可以自动将录音、视频,图像,聊天记录等按照档案记录下来。(此处修改可操作连接图灵机器人,将提问和回答的信息记录下来。作为自己训练的原始数据集)
其中全局参数全球温度:
temp是一个列表,可以将最近的消息加入列表,该消息信息是字典格式的所有消息包含的原始数据。比如消息类型,发送人,接收人等等。
#, - *安康;编码:utf-8 - * - “““ Created 提醒Fri Jul 19 13:10:01 2019 @author: wenzhe.tian “““ import wxpy  as wp 得到collections import  defaultdict import pandas  as pd 得到tkinter import 对话框 import 操作系统 时间=bot wp.Bot (cache_path=True) 聊天=bot.chats(), #,所有开启了聊天窗口的对象 组=bot.groups(), #,所有群的对象 朋友=bot.friends(), #,所有好友的对象 议员=bot.mps(), #,所有公众号的对象 @bot.register () def print_messages(味精): ,打印(msg.create_time、味精) global 临时 ,if msg.sender.nick_name  message.keys拷贝(): 消息(msg.sender.nick_name)才能.append (msg.raw) ,其他的: 消息才能[msg.sender.nick_name]=[] 消息(msg.sender.nick_name)才能.append (msg.raw) , ,路径=& # 39;C: \ \ \ \ wenzhe.tian \ \用户桌面\ \ send_mail \ \ wechat_infomation \ \ & # 39;,, #,修改为希望存储聊天,推送,图片,视频,音频等信息的地址 ,if os.path.exists(路径+ msg.sender.nick_name)==False: os.makedirs才能(路径+ msg.sender.nick_name) ,if msg.type==& # 39;文本# 39;: f =,开放才能(路径+ msg.sender.nick_name + & # 39; \ \ message.txt& # 39;, & # 39; a + & # 39;,编码=& # 39;utf - 8 # 39;) f.read才能() f.write才能(& # 39;\ n # 39;) f.write才能(str (msg.create_time) + msg.text) f.close才能() ,其他的: 打印才能(& # 39;非文字消息,已存储& # 39;) if 才能;& # 39;强生# 39;,拷贝msg.file_name: ,,msg.get_file (save_path=路径+ msg.sender.nick_name + & # 39; \ \ & # 39; + msg.file_name) 其他的才能: ,,msg.get_file (save_path=路径+ msg.sender.nick_name + & # 39; \ \ & # 39; + msg.file_name + & # 39; . txt # 39;)怎么用python wxpy管理微信公众号并利用微信获取自己的开源数据