zoukankan      html  css  js  c++  java
  • Python实现微信祝福语自动发送

    背景:源于生活中的各种假期节气,微信祝福漫天飞舞~

    想要通过Python来实现自动发送微信祝福语给好友~

    方法一:

    借用现有接口,自动生成配套的订阅号二维码及key

    关于此API请查阅相关链接:http://pushbear.ftqq.com/admin/#/

    直接上代码

    import requests
    url = 'https://pushbear.ftqq.com/sub'
    def send_auto():
    data={
    'text':'Happy the year of Pig',#标题
    'desp':'lol~ Words alone cannot fully express my heartfelt wishes to you and your family~Jolin, She may you, your family, and your loved ones have a Year of the Pig filled with prosperity,good fortune and more importantly - health! '
    'sendkey':'10643-f20d157c83e36d4b8bc08f84563fe77d'#由官方配置而来的key
    }
    requests.get(url,data)
    return requests.get(url,data).text
    send_auto()

    个人感觉,如上方法实现的简单(只需要填写需要发送消息的标题,内容,配合配套的key),但需要对方扫码订阅此公众号,且对于发送的频率、重复内容还有各种限制,不够灵活


    方法二 借用wechat官方机器人
    直接上代码
    from wxpy import *
    import time
    # #初始化机器人扫码登录
    bot = Bot()
    time.sleep(10)
    my_friend = bot.friends()
    # 挨个发送祝福语(此处可以优化,先判断对方是否仍为自己好友,以后咯)
    for i in range (1,len(my_friend)):
    my_friend[i].send_msg(str(my_friend[i].name) + 'Happy every day!')
    time.sleep(1)

    #关于bot机器人,请查阅相关API文档




  • 相关阅读:
    Java:求字符串中邻接的数字为一个整体
    在jsp提交表单的参数封装到一个方法里
    synchronized
    java内存模型JMM
    多线程学习:线程基础
    集合框架总结与开发遇到的问题
    HashSet、LinkedHashSet学习笔记
    Iterable、Collection、AbstractConlltion、List学习笔记
    LinkedList学习笔记
    LinkedHashMap
  • 原文地址:https://www.cnblogs.com/digitalNatives/p/10526061.html
Copyright © 2011-2022 走看看