相关文章推荐
茫然的煎饼  ·  Python ...·  1 周前    · 
茫然的煎饼  ·  Get Up and Running ...·  9 月前    · 
茫然的煎饼  ·  【TS】一、类型注解 ·  9 月前    · 
茫然的煎饼  ·  ios html5 video m3u8 ...·  9 月前    · 
茫然的煎饼  ·  CPLEX出现'q1' is not ...·  10 月前    · 
严肃的皮蛋  ·  Retrieve Original ...·  18 小时前    · 
严肃的围巾  ·  C++内部函数与外部函数 | ...·  18 小时前    · 
性感的绿豆  ·  SQL ...·  18 小时前    · 
完美的充值卡  ·  A Basic AWS Lambda ...·  18 小时前    · 
import requests
# Python源码资料电子书领取群 279199867

def send_wechat(msg):
    token = 'XXXXXXXXXXXX'#前边复制到那个token
    title = 'title1'
    content = msg
    template = 'html'
    url = f"https://www.pushplus.plus/send?token={token}&title={title}&content={content}&template={template}"
    print(url)
    r = requests.get(url=url)
    print(r.text)

if __name__ == '__main__':
    msg = 'Life is short I use python'
    send_wechat(msg)

在手机上看一下结果

局限性:这个只能给自己推送,别人推送不了。那怎么给别人推送呢?

# 一对多推送

1、在一对多推送的tab页面里,新建群组,并记录下群组编码。

2、点击生成二维码,将二维码发给要接受消息的人。让他们用微信扫码。


3、扫码后,看看订阅人,扫码之后的人,会显示在这里。给这个群组发送的消息,这里的人都会接收到。


4、写代码发送消息到微信

import requests

def send_wechat(msg):
    token = ' XXXXXXXXXXXXXXXXXX' #前边复制到那个token
    title = 'test notice title'
    content = msg
    template = 'html'
    topic = '1'
    url = f"http://www.pushplus.plus/send?token={token}&title={title}&content={content}&template={template}&topic={topic}"
    print(url)
    r = requests.get(url=url)
    print(r.text)

if __name__ == '__main__':
    msg = 'this is a one to more lizi'
    send_wechat(msg)

至此到这里就完成啦!

另注:pushplus 分普通用户和会员,他们最大的区别就是:普通用户一天仅可请求200次,会员扩大到1000次。所以普通用户基本上也够用了。真想支持网站作者,就买个会员,一个月也就10块钱。

--- EOF ---
 
推荐文章