mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
Merge pull request #1495 from Ghlerrix/pushUrl
[fix] 修复pushUrl未配置相关Secrets报错邮件
This commit is contained in:
24
.github/workflows/pushUrl.yml
vendored
24
.github/workflows/pushUrl.yml
vendored
@@ -36,4 +36,26 @@ jobs:
|
||||
run: pip install requests
|
||||
|
||||
- name: Push
|
||||
run: python pushUrl.py --url ${{ secrets.URL }} --baidu_token ${{ secrets.BAIDU_TOKEN }} --bing_api_key ${{ secrets.BING_API_KEY }}
|
||||
env:
|
||||
URL: ${{ secrets.URL }}
|
||||
BAIDU_TOKEN: ${{ secrets.BAIDU_TOKEN }}
|
||||
BING_API_KEY: ${{ secrets.BING_API_KEY }}
|
||||
run: |
|
||||
if [ -n "$URL" ]; then
|
||||
if [ -n "$BAIDU_TOKEN" ]; then
|
||||
python pushUrl.py --url $URL --baidu_token $BAIDU_TOKEN
|
||||
else
|
||||
echo "请前往 Github Action Secrets 配置 BAIDU_TOKEN:"
|
||||
echo "详情参见: 'https://www.ghlcode.cn/fe032806-5362-4d82-b746-a0b26ce8b9d9'"
|
||||
fi
|
||||
if [ -n "$BING_API_KEY" ]; then
|
||||
python pushUrl.py --url $URL --bing_api_key $BING_API_KEY
|
||||
else
|
||||
echo "请前往 Github Action Secrets 配置 BING_API_KEY:"
|
||||
echo "详情参见: 'https://www.ghlcode.cn/fe032806-5362-4d82-b746-a0b26ce8b9d9'"
|
||||
fi
|
||||
else
|
||||
echo "请前往 Github Action Secrets 配置 URL:"
|
||||
echo "详情参见: 'https://www.ghlcode.cn/fe032806-5362-4d82-b746-a0b26ce8b9d9'"
|
||||
fi
|
||||
|
||||
|
||||
13
pushUrl.py
13
pushUrl.py
@@ -15,12 +15,9 @@ QUOTA = 100
|
||||
|
||||
def parse_stiemap(site):
|
||||
site = f'{site}/sitemap.xml'
|
||||
print('解析站点地图中,请稍后……')
|
||||
try:
|
||||
result = requests.get(site)
|
||||
big = re.findall('<loc>(.*?)</loc>', result.content.decode('utf-8'), re.S)
|
||||
print('当前已有url:')
|
||||
print(list(big))
|
||||
return list(big)
|
||||
except:
|
||||
print('请检查你的url是否有误。')
|
||||
@@ -70,7 +67,7 @@ def push_to_baidu(site, urls, token):
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='parse sitemap')
|
||||
parser.add_argument('--url', type=str, help='The url of your website')
|
||||
parser.add_argument('--url', type=str, default=None, help='The url of your website')
|
||||
parser.add_argument('--bing_api_key', type=str, default=None, help='your bing api key')
|
||||
parser.add_argument('--baidu_token', type=str, default=None, help='Your baidu push token')
|
||||
args = parser.parse_args()
|
||||
@@ -88,16 +85,12 @@ if __name__ == '__main__':
|
||||
urls = random.sample(urls, QUOTA)
|
||||
# 推送bing
|
||||
if args.bing_api_key:
|
||||
print('正在推送至必应,请稍后……')
|
||||
push_to_bing(args.url, urls, args.bing_api_key)
|
||||
else:
|
||||
print('未配置 Bing API Key')
|
||||
print('详情参见: https://ghlcode.cn/fe032806-5362-4d82-b746-a0b26ce8b9d9')
|
||||
# 推送百度
|
||||
if args.baidu_token:
|
||||
print('正在推送至百度,请稍后……')
|
||||
push_to_baidu(args.url, urls, args.baidu_token)
|
||||
else:
|
||||
print('未配置 Baidu Token')
|
||||
print('详情参见: https://ghlcode.cn/fe032806-5362-4d82-b746-a0b26ce8b9d9')
|
||||
else:
|
||||
print('请前往 Github Action Secrets 配置 URL')
|
||||
print('详情参见: https://ghlcode.cn/fe032806-5362-4d82-b746-a0b26ce8b9d9')
|
||||
|
||||
Reference in New Issue
Block a user