python微信库:itchat
2017-12-21 09:29
956 查看
因为最近的项目,需要使用微信的接口获取一些数据。
参考:python实现微信接口(itchat)
安装:pip install itchat
常见接口使用:
import itchat
import pandas an pd
1、登录
itchat.login()
itchat.auto_login()
这种方法将会通过微信扫描二维码登录,但是这种登录的方式确实短时间的登录,并不会保留登录的状态,也就是下次登录时还是需要扫描二维码,如果加上hotReload==True,那么就会保留登录的状态,至少在后面的几次登录过程中不会再次扫描二维码,该参数生成一个静态文件itchat.pkl用于存储登录状态
2、获取好友列表
itchat.get_friends(update=True)
3、导出好友列表
df_friends = pd.DataFrame(friends)
df_friends.to_csv(‘friends.csv’, encoding=’utf-8’,index = False)
发送消息
send(msg=”Text Message”, toUserName=None)
参数
msg : 文本消息内容
@fil@path_to_file : 发送文件
@img@path_to_img : 发送图片
@vid@path_to_video : 发送视频
toUserName : 发送对象, 如果留空, 将发送给自己.
返回值
True or False
实例代码
- send_msg
- send_file
-send_image
- send_video
参考:python实现微信接口(itchat)
安装:pip install itchat
常见接口使用:
import itchat
import pandas an pd
1、登录
itchat.login()
itchat.auto_login()
这种方法将会通过微信扫描二维码登录,但是这种登录的方式确实短时间的登录,并不会保留登录的状态,也就是下次登录时还是需要扫描二维码,如果加上hotReload==True,那么就会保留登录的状态,至少在后面的几次登录过程中不会再次扫描二维码,该参数生成一个静态文件itchat.pkl用于存储登录状态
2、获取好友列表
itchat.get_friends(update=True)
3、导出好友列表
df_friends = pd.DataFrame(friends)
df_friends.to_csv(‘friends.csv’, encoding=’utf-8’,index = False)
发送消息
send(msg=”Text Message”, toUserName=None)
参数
msg : 文本消息内容
@fil@path_to_file : 发送文件
@img@path_to_img : 发送图片
@vid@path_to_video : 发送视频
toUserName : 发送对象, 如果留空, 将发送给自己.
返回值
True or False
实例代码
# coding-utf-8 import itchat itchat.auto_login() itchat.send("Hello World!") ithcat.send("@fil@%s" % '/tmp/test.text') ithcat.send("@img@%s" % '/tmp/test.png') ithcat.send("@vid@%s" % '/tmp/test.mkv')
- send_msg
itchat.send_msg("hello world.")
- send_file
itchat.send_file("/tmp/test.txt")
-send_image
itchat.send_img("/tmp/test.txt")
- send_video
itchat.send_video("/tmp/test.txt")
相关文章推荐
- Python微信库: itchat
- Python微信库:itchat的用法详解
- 安装python itchat 模块 用python发微信消息
- 用python itchat包 爬取微信好友头像形成矩形头像集
- Python学习-Itchat微信API
- Python实现微信好友签名词云的构建(itchat、jieba、wordcloud)
- 利用python微信库itchat实现微信自动回复功能
- Python itchat个人微信账号接口定时发送群消息
- Python利用itchat对微信中好友数据实现简单分析的方法
- 【itchat】用Python玩耍微信
- python实现微信接口(itchat)
- 使用Python微信库itchat获得好友和群组已撤回的消息
- python实现微信接口(itchat)
- python实现微信接口(itchat)详细介绍
- 在python中使用itchat发送微信消息
- python使用itchat发送微信消息提醒
- python微信模块 itchat
- python实现微信接口(itchat)
- Python之itchat生成微信头像拼接问题
- python实现微信接口(itchat)