50 行 Python 代码,带你追到女神

今天来给大家分享一个撩妹技巧,利用 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


posted @   IT_吴彦祖  阅读(693)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示

"Buy Me A Coffee"