python发送微信消息脚本(python实现微信每日一句自动发送给喜欢的人)
类别:脚本大全 浏览量:1775
时间:2021-10-14 00:29:33 python发送微信消息脚本
python实现微信每日一句自动发送给喜欢的人本文实例为大家分享了python实现微信每日一句自动发送的具体代码,供大家参考,具体内容如下
参考了一篇博客:教你使用python实现微信每天给女朋友说晚安
代码:
|
# -*- coding: utf-8 -*- ''' 这是一个用来测试微信自动发送消息的demo 恩,主要就是用到了一个微信库--wxpy 安装很简单 pip install wxpy 下面就开始吧 主要就两个函数 1、getnews();用以获取信息 2、sendnews();用以发送信息 我这里发送消息用的是for循环本意是群发,但是!但是!但是!程序发的太快会被微信禁掉,大概40个人左右就会被禁,以后可以试试sleep一下。 另外vscode中自定义python编译器: ctrl+shift+p, 选择 python: select interpreter ''' from __future__ import unicode_literals from wxpy import * import requests from threading import timer itchat = bot(console_qr = 2 ,cache_path = "botoo.pkl" ) def getnews(): url = "http://open.iciba.com/dsapi/" r = requests.get(url) content = r.json()[ 'content' ] note = r.json()[ 'note' ] return content, note def sendnews(): try : #这里是备注 friend = itchat.friends().search(name = u 'xxx' ) content = getnews() print (content) message1 = str (content[ 0 ]) message2 = str (content[ 1 ]) message3 = "xxx" print (friend) for index,item in enumerate (friend): print ( "发送给 " + str (item) + " ing,index=" + str (index)) item.send(message1) item.send(message2) item.send(message3) t = timer( 86400 ,sendnews) t.start() except : errormessage = "xxx" for index,item in enumerate (friend): item.send(errormessage) if __name__ = = "__main__" : sendnews() |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持开心学习网。
原文链接:https://blog.csdn.net/u011554976/article/details/80604004
您可能感兴趣
- python中的time时间模块使用知识(python实现简单日期工具类)
- python怎么判断文件大小(python3实现指定目录下文件sha256及文件大小统计)
- python3常见问题(对Python3使运行暂停的方法详解)
- python爬虫怎么爬取vip资源(Python网络爬虫之爬取微博热搜)
- python 聚类找出同一类别的数据(Python实现简单层次聚类算法以及可视化)
- 未来10年python前景(Python应用领域和就业形势分析总结)
- pythonrequests爬虫使用教程(Python 通过requests实现腾讯新闻抓取爬虫的方法)
- 最简单python的100个代码(20条非常实用的Python代码实例)
- python变量指向讲解(详解python中init方法和随机数方法)
- python基本运算符编程(对Python3 * 和 ** 运算符详解)
- python 获取ip mac 地址(Python3获取电脑IP、主机名、Mac地址的方法示例)
- python调用excel教程(利用python在excel里面直接使用sql函数的方法)
- python 文本分析 摘要(用Python逐行分析文件方法)
- python的log函数(Python3 log10函数简单用法)
- python3.7标准库官方手册(Python3.7 dataclass使用指南小结)
- python多线程多进程运行场景(Python多线程同步---文件读写控制方法)
- 医事文化谈屑 | 古人的名 字 号(医事文化谈屑古人的名)
- ()
- 网友很惭愧,自己写了很多年的字,到头来还不如一名小学生写的好(自己写了很多年的字)
- 中华第一楷 张瑞龄 86岁高龄,苦练楷书71年,一幅字卖593万(中华第一楷张瑞龄)
- 冯骥才 年意(冯骥才年意)
- ()
热门推荐
- dedecms 图片不显示(dedecms图片集添加水印的方法)
- angular快速创建模块指令(详解Angular项目中共享模块的实现)
- python实现栈和队列(Python利用heapq实现一个优先级队列的方法)
- ecs设置(如何解决ECS Windows提示显示设置无法从远程会话进行更改)
- web服务器架设和管理(浅谈Web服务器的安装与配置)
- sql server设置标识列(Sql Server 如何去掉内容里面的Html标签)
- C#中string.format的格式和用法
- sqlserver表分区步骤(行转列之SQL SERVER PIVOT与用法详解)
- 什么是mongodb 固定集合
- dedecms添加代码(dedecms内容页调用栏目链接和栏目名称的方法)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9