利用itchat库实现微信自动定时发送消息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#coding:utf-8
import itchat
import time

itchat.auto_login()

users = itchat.search_friends(name=u'通讯录备注')
userName = users[0]['UserName']


while True:
time_now = time.strftime('%H%M',time.localtime(time.time()))
if int(time_now) == 2300:
itchat.send(u'内容', toUserName = userName)
time.sleep(60)
if int(time_now) == 615:
itchat.send(u'内容',toUserName = userName)
time.sleep(60)
if int(time_now) == 1200:
itchat.send(u'内容',toUserName = userName)
time.sleep(60)
script>