• 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

    
    
  • 相关阅读:
    最小点割集
    哈希链表形式
    poj 1809
    整数的分拆
    Dynamic Rankings
    Error on line 1 of document
    怎么样用JAVA取得系统的路径?
    Richfaces优化,Richfaces为何这么慢?
    null Nested exception: null
    帮助你生成组织结构图的jQuery插件 jOrgChart java程序员
  • 原文地址:https://www.cnblogs.com/AlexZha/p/9197346.html
Copyright © 2020-2023  润新知