使用wxpy自动发送微信消息
思路整理:1、进入心灵鸡汤网页,使用python获取心灵鸡汤内容
2、登陆微信,找到需要发送的朋友
3、发送获取的内容
1、获取心灵鸡汤的内容
如下图,获取第一条鸡汤
实现如下:

2、登陆微信,搜索朋友,进行发送
import requests
import wxpy
from bs4 import BeautifulSoup
# 微信网页登陆
bot = wxpy.Bot(console_qr=2,cache_path='botoo.pkl')
# 获取心灵鸡汤中的最新内容,可以参考其他爬虫随便查看怎么爬虫
def get_msg():
url = 'http://www.59xihuan.cn/index_1.html'
h = requests.get(url)
html = h.text
news_bf = BeautifulSoup(html,"html.parser")
msg = news_bf.find('div', class_='pic_text1')
news = msg.text
# print(msg)
# print(news)
return news
# 给朋友发送消息
def send_msg():
try:
# 添加朋友微信昵称
friend = bot.friends().search(u'xxxxx')[0]
friend.send(get_msg())
# 发送消息
t = wxpy.Timer(1,send_msg)
t.start()
except:pass
if __name__ == '__main__':
send_msg()朋友收到的消息:

有兴趣的可以参考笔者的爬取小说随笔,爬下心灵鸡汤的多条鸡汤和图片,然后发送朋友鸡汤和配图
如果恶搞的话可以去详细了解wxpy的使用,每秒发送朋友x条内容,持续y时间
相关推荐
jieq 2020-11-09
znbvx 2020-11-13
liduote 2020-11-13
umengren 2020-11-11
郑贺腾讯社交广告 2020-11-06
wuxiaobo 2020-11-06
jcwang 2020-11-03
Dayer 2020-10-27
Elyn 2020-10-24
虞凌云 2020-09-28
huavhuahua 2020-09-21
lookat 2020-09-18
QSmile 2020-09-17
fanxiaoxuan 2020-09-17
Allinputs 2020-08-30
xjygabc00 2020-09-11
gxq 2020-09-10
Tomato 2020-09-10