| 224 | print('推送失败!') |
| 225 | # push推送 |
| 226 | def pushplus_bot(title, content): |
| 227 | try: |
| 228 | print("\n") |
| 229 | if not PUSH_PLUS_TOKEN: |
| 230 | print("PUSHPLUS服务的token未设置!!\n取消推送") |
| 231 | return |
| 232 | print("PUSHPLUS服务启动") |
| 233 | url = 'http://www.pushplus.plus/send' |
| 234 | data = { |
| 235 | "token": PUSH_PLUS_TOKEN, |
| 236 | "title": title, |
| 237 | "content": content |
| 238 | } |
| 239 | body = json.dumps(data).encode(encoding='utf-8') |
| 240 | headers = {'Content-Type': 'application/json'} |
| 241 | response = requests.post(url=url, data=body, headers=headers).json() |
| 242 | if response['code'] == 200: |
| 243 | print('推送成功!') |
| 244 | else: |
| 245 | print('推送失败!') |
| 246 | except Exception as e: |
| 247 | print(e) |
| 248 | |
| 249 | |
| 250 | |