在python中使用wxpy模块
安装
pip install wxpy
使用
#导入模块
from wxpy import *
#初始化机器人,扫码登陆
bot = Bot()
找到好友
#搜索名称含有 “name” 的男性上海好友
my_friend = bot.friends().search('name', sex=MALE, city="上海")[0]
发送消息:
#发送文本给好友
my_friend.send('Hello WeChat!')
#发送图片
my_friend.send_image('my_picture.jpg')
移植到linux服务器的登录问题
之前微信扫描二维码不识别,console设置成1,2,True均不行,修改成-2后成功。
此段代码为金山词霸的每日一句英文。
#/usr/bin/env python
from threading import Timer
import requests
from wxpy import *
##bot = Bot()
bot = Bot(console_qr=-2,cache_path=True) #移植到linux,console_qr设置True和2都无法扫描登录