使用wxpy实现自动发送微信消息功能

作者:Tynam.Yang 时间:2022-04-01 21:16:06 

思路整理:1、进入心灵鸡汤网页,使用python获取心灵鸡汤内容

2、登陆微信,找到需要发送的朋友

3、发送获取的内容

1、获取心灵鸡汤的内容

如下图,获取第一条鸡汤

使用wxpy实现自动发送微信消息功能

实现如下:

使用wxpy实现自动发送微信消息功能

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())
   29   except:pass
if __name__ == '__main__':
 send_msg()

其他发送类型格式:

  • 发送文本消息:friend.send('文本消息')

  • 发送图片消息:friend.send_image('图片消息.jpg')

  • 发送视频消息:friend.send_video('视频消息.mov')

  • 发送文件消息:friend.send_file('文件消息.zip')

  • 以动态的方式发送图片:friend.send('@img@图片消息.jpg')

朋友收到的消息:

使用wxpy实现自动发送微信消息功能

来源:https://www.cnblogs.com/tynam/p/9106461.html

标签:wxpy,发送,微信,消息
0
投稿

猜你喜欢

  • Python函数关键字参数及用法详解

    2023-08-13 00:34:06
  • 使用javascript修复浏览器中12个常见而又头痛的问题

    2008-10-28 19:38:00
  • PHP使用redis实现分布式锁的示例详解

    2023-06-01 16:32:19
  • Web 标准设计实践:Google 的首页

    2008-10-12 12:14:00
  • 用asp编写文档搜索页面

    2008-01-13 07:04:00
  • 分享4个Python中的非常好用的自动化脚本

    2023-12-03 09:59:17
  • ASP文件中的安全问题

    2011-04-14 11:15:00
  • 用python实现一个简单的验证码

    2023-05-23 12:07:58
  • jsp自定义标签之ifelse与遍历自定义标签示例

    2023-06-25 21:09:34
  • CSS 3入门

    2009-04-19 13:00:00
  • asp检测是否为中文字符函数

    2011-04-07 11:19:00
  • 从Web查询数据库之PHP与MySQL篇

    2009-09-19 16:58:00
  • 设计英文网站要注意的问题

    2011-04-28 11:22:00
  • 一段查看ASP文件源码的ASP程序

    2007-09-21 12:53:00
  • 关于SQL中CTE(公用表表达式)(Common Table Expression)的总结

    2012-08-21 10:22:21
  • python新式类和经典类的区别实例分析

    2023-07-28 10:01:02
  • JavaScript中常见的几种获取元素的方式

    2023-07-13 07:46:12
  • Python中利用原始套接字进行网络编程的示例

    2023-06-22 18:02:03
  • Flash连接服务器

    2008-06-15 07:19:00
  • Python 读取某个目录下所有的文件实例

    2022-08-27 20:04:13
  • asp之家 网络编程 m.aspxhome.com