Loading... 效果图 ![微信图片_20220823120306.jpg](https://woain.cn/usr/uploads/2022/08/4178348043.jpg) **第一步 打开微信申请测试号[http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index](http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index)** 进行扫码登录 ![微信图片_20220823120525.jpg](https://woain.cn/usr/uploads/2022/08/1562303129.jpg) 获取到了两个非常重要的东西 **appID**和**appsecret** **一定不要给别人!!!** 接下来就是扫码 关注测速号 会在右面出现 昵称 和 微信号 ![微信图片_20220823120742.jpg](https://woain.cn/usr/uploads/2022/08/3019704214.jpg) 获取到之后就是增加模板了![微信图片_20220823120854.jpg](https://woain.cn/usr/uploads/2022/08/892964819.jpg) 标题随意 内容填写 ``` {{date.DATA}} 地区:{{region.DATA}} 天气:{{weather.DATA}} 气温:{{temp.DATA}} 风向:{{wind_dir.DATA}} 今天是我们恋爱的第{{love_day.DATA}}天 {{birthday1.DATA}} {{birthday2.DATA}} {{note_en.DATA}} {{note_ch.DATA}} ``` 之后就获取到了模板id 然后 <button class=" btn m-b-xs btn-primary btn-rounded " onclick="">[点击下载](https://pan.woain.cn/api/v3/file/source/159/weixin.zip?sign=0gLgf-BYpunf10yZNn6m2Xs_bVhMmPEiN30CitZXXQw%3D%3A0)</button>需要挂到服务器上的文件 打开config.txt文件如下所示: ``` { # 公众号配置 # 公众号appId "app_id": "", # 公众号appSecret "app_secret": "", # 模板消息id "template_id": "", # 接收公众号消息的微信号,如果有多个,需要在[]里用英文逗号间隔,例如["wx1", "wx2"] "user": [""], # 信息配置 # 和风天气apikey "weather_key": "", # 所在地区,可为省,城市,区,县,同时支持国外城市,例如伦敦 "region": "", # 生日1,修改名字为对应需要显示的名字,如果生日为农历,在最前面加上r即可 "birthday1": {"name": "名字", "birthday": "2001-01-01"}, # 生日2 "birthday2": {"name": "名字", "birthday": "2001-01-01"}, # 在一起的日子,格式同上,暂不不支持农历 "love_date": "2001-01-01", # 金句中文,如果设置了,则会显示这里的,如果为空,默认会读取金山的每日金句 "note_ch": "", # 金句英文 "note_en": "study hard and make progress every day!" } ``` 然后 百度搜索和风天气控制台,进行注册登录,[https://id.qweather.com/](https://id.qweather.com/) 随后进入![微信图片_20220823121359.jpg](https://woain.cn/usr/uploads/2022/08/998260866.jpg) 和风天气开发者控制台,点击应用管理,选择免费开发版,KEY类型选择 WebAPI ![微信图片_20220823121534.jpg](https://woain.cn/usr/uploads/2022/08/2359924592.jpg) **这个key就是我们需要填写在config.txt中的weather_key。** 随后就填写所在城市、生日、什么时候在一起的即可,**然后保存。** 最后打开main.py文件在pycharm里运行,运行Py文件需要新建一个项目,如果不会,请自行百度。 运行之后会在控制台提示推送消息成功,此时对方就收到了推送消息。 我们部署到服务器 首先安装宝塔 Centos命令 `yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh` 服务器只要安装过宝塔一般都会安装python 所以不用执行这个 `yum install python3.6` 找到宝塔面板 文件--> www![dd8b09764706460cdc1de42e8cd1e544.png](https://woain.cn/usr/uploads/2022/08/1250841956.png) 在www文件夹下新建文件夹 上传你刚才改好的文件 需要安装模块 request和zhdate 命令 `python3 -m pip install requests` `python3 -m pip install zhdate` 右键 打开终端 ![33958cabb000fbf5642c9f3b6138625a.png](https://woain.cn/usr/uploads/2022/08/526478902.png) 输入`python3.6 main.py` 显示推送成功即成功推送 设置定时计划实现每天自动发送一次 ![2e6baae1ceb7abfd5c476903422a4b64.png](https://woain.cn/usr/uploads/2022/08/3654490456.png) ![954699af2084cf19aa8fd91d423eb0e6.png](https://woain.cn/usr/uploads/2022/08/2140908997.png) 自己设置执行周期 每天9小时30分即可 别太早吵醒女朋友睡觉 后果很严重 运行效果图 ![f06c04f833c8609b4356c7633e5285b7.png](https://woain.cn/usr/uploads/2022/08/34392187.png) 最后修改:2022 年 08 月 23 日 © 允许规范转载 打赏 赞赏作者 赞 1 如果觉得我的文章对你有用,请随意赞赏