介绍
使用wxpy怎么自动发送微信消息?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
思路整理:1,进入心灵鸡汤网页,使用python获取心灵鸡汤内容
2,登陆微信,找到需要发送的朋友
3,发送获取的内容
实现如下:
2,登陆微信,搜索朋友,进行发送
import 请求 import wxpy 得到bs4 import  BeautifulSoup #,微信网页登陆 时间=bot wxpy.Bot (console_qr=2, cache_path=& # 39; botoo.pkl& # 39;) #,获取心灵鸡汤中的最新内容,可以参考其他爬虫随便查看怎么爬虫 def get_msg (): 时间=url 才能;& # 39;http://www.59xihuan.cn/index_1.html& # 39; 时间=h 才能;requests.get (url) html 才能=h.text 时间=news_bf 才能;BeautifulSoup (html、“html.parser") msg 才能=,news_bf.find (& # 39; div # 39;,, class_=& # 39; pic_text1& # 39;) news 才能=msg.text #,才能打印(味精) #,才能打印(新闻) return 才能;新闻 #,给朋友发送消息 def send_msg (): 尝试才能: ,,,#,添加朋友微信昵称 ,,,friend =, bot.friends () .search (u # 39; xxxxx # 39;) [0] ,,,friend.send (get_msg ()) 29日,,,,,,除了:通过 if __name__ ==, & # 39; __main__ # 39;: send_msg才能()
其他发送类型格式:
- <李>
发送文本消息:friend.send(& # 39;文本消息& # 39;)
李> <李>发送图片消息:friend.send_image(& # 39;图片消息jpg # 39;)
李> <李>发送视频消息:friend.send_video(& # 39;视频消息。mov # 39;)
李> <李>发送文件消息:friend.send_file(& # 39;文件消息. zip # 39;)
李> <李>以动态的方式发送图片:friend.send (& # 39; @img@图片消息jpg # 39;)
李>看完上述内容,你们掌握使用wxpy怎么自动发送微信消息的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!