benpao-yezi
# -*- coding: UTF-8 -*-
import itchat
import time
import requests
#获取金山词霸每日一句
def get_new():
url="http://open.iciba.com/dsapi"
r=requests.get(url)
contents=r.json()[\'content\']
note=r.json()[\'note\']
    return contents,note
def send_news():
try:
itchat.auto_login(hotReload=True)
my_friend=itchat.search_friends(name=u\'卡2\')
FriendName=my_friend[0]["UserName"]
message1=get_new()[0]
#因为会出现进程报错,所以我加上了 pass
pass
message2=get_new[1]
pass
message3=u"来自你的朋友"
pass
itchat.send(message1,toUserName=FriendName)
itchat.send(message2, toUserName=FriendName)
itchat.send(message3, toUserName=FriendName)
#每个1天发送消息
t=time(86400,send_news())
t.start()

except:
#如果上面其中一条消息没有发送成功,就会发送本条消息
message4=u"你的朋友出bug了"
itchat.send(message4,toUserName=FriendName)

if __name__=="__main__":
send_news()

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-08-05
  • 2022-12-23
  • 2021-09-26
  • 2021-07-26
  • 2021-10-31
  • 2021-12-05
  • 2022-12-23
猜你喜欢
  • 2021-11-19
  • 2021-12-12
  • 2021-12-12
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案