微信定时发送源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding:gbk -*-
# 导入模块
from wxpy import *
import time
import random

bot = Bot()
# 初始化机器人,扫码登陆

def send_news():
data=[]
data.append('xxx')

n=0
while 1:
try:

my_friend = bot.friends().search(u'Zkk')[0] #你朋友的微信名称,不是备注,也不是微信帐号。

my_friend.send(data[n])
n+=1
if n==len(data):
return
time.sleep(480)
except:
my_friend = bot.friends().search('Zkk')[0]#你的微信名称,不是微信帐号。
my_friend.send(u"今天消息发送失败了")
if __name__ == "__main__":
send_news()