From 068b68e6dee00a2846f7f91a8511dfa8d5261bc0 Mon Sep 17 00:00:00 2001 From: ngfchl Date: Tue, 25 Apr 2023 10:45:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=B9=BF=E5=91=8A=E5=90=8Ebark=E9=80=9A=E7=9F=A5=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_site/UtilityTool.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pt_site/UtilityTool.py b/pt_site/UtilityTool.py index 2ec5006..5c4b395 100644 --- a/pt_site/UtilityTool.py +++ b/pt_site/UtilityTool.py @@ -8,6 +8,7 @@ import ssl import threading import time import traceback +import urllib.parse from datetime import datetime from urllib.request import urlopen @@ -127,9 +128,12 @@ class PtSpider: def select_ad(self): # res = requests.get('http://api.ptools.fun/select_ad') ads = [ - 'PTools目前开发遇到困难,开发电脑性能不足,时常崩溃,欢迎赞助!', - '为补贴开发,努力卖点农副产品,自家生纯净榨核桃油,如有需要欢迎联系我!', - '广告位招租哟,欢迎投放广告!', + 'PTools目前开发遇到困难,开发电脑性能不足,时常崩溃,欢迎赞助!' + '', + '为补贴开发,努力卖点农副产品,自家生纯净榨核桃油,如有需要欢迎联系我!' + '', + '广告位招租哟,欢迎投放广告!' + '', ] return random.choice(ads) @@ -180,9 +184,17 @@ class PtSpider: logger.info(msg) if notify.name == PushConfig.bark_push: - url = f'{notify.custom_server}{notify.corpsecret}/{title}/{message}' - res = self.get_scraper().get(url=url) - msg = 'bark通知{}'.format(res) + res = requests.post( + url=f'{notify.custom_server}push', + data={ + 'title': title, + 'body': message, + 'device_key': notify.corpsecret, + 'url': 'http://img.ptools.fun/pay.png', + 'icon': 'https://gitee.com/ngfchl/ptools/raw/master/static/logo4.png' + }, + ) + msg = 'bark通知 {}'.format(res.json()) logger.info(msg) if notify.name == PushConfig.iyuu_push: