今天来给大家分享一个撩妹技巧,利用 python 每天给你最心爱的人,发送微信消息,说声晚安。

废话不多说,源代码奉上

def get_news():
...     url = "http://open.iciba.com/dsapi"
...     r = request.get(url)
...     contents = r.json()['content']
...     translation = r.json()['translation']
...     return contents, translation
...
def send_news():
...     try:
...             itchat.auto_login(hotReload=True)
...             my_friend = itchat.search_friends(name=u'Alice')
...             Alice = my_friend[0]["UserName"]
...             message1 = str(get_news()[0])
...             content = str(get_news()[1][17:])
...             message2 = str(content)
...             message3 = "来自爱你得人"
...             itchat.send(message1,toUserName=Alice)
...             itchat.send(message2,toUserName=Alice)
...             itchat.send(message3,toUserName=Alice)
...             t= time(86400,send_news())
...             t.start()
...     except:
...             message4 = u"今天最爱你得人出现啦 bug /(ToT)/~~"
...             itchat.send(message4,toUserName=Alice)

最后只要调用一下sendnews方法,然后保证后台运行,微信就会每天给你心爱得人发送消息了

忘记说了,还要引用几个包

import  request

import  itchat

import time


 
                    
            
                

相关文章:

  • 2021-08-30
  • 2021-01-20
  • 2021-11-04
  • 2022-01-02
  • 2021-04-28
  • 2021-10-05
  • 2021-04-03
  • 2022-01-22
猜你喜欢
  • 2021-10-10
  • 2021-04-05
  • 2021-07-16
  • 2021-08-25
相关资源
相似解决方案