mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-09 07:26:47 +00:00
39
.github/workflows/baidupush.yml
vendored
Normal file
39
.github/workflows/baidupush.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
## 利用GitHub Actions每天定时给百度推送链接,提高收录率 ##
|
||||||
|
|
||||||
|
name: baidupush
|
||||||
|
|
||||||
|
# 两种触发方式:一、push代码,二、每天国际标准时间23点(北京时间+8即早上7点)运行
|
||||||
|
on:
|
||||||
|
# push:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 23 * * *' # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#scheduled-events-schedule
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
unconditional-invoking:
|
||||||
|
description: 'baidupush unconditionally'
|
||||||
|
type: boolean
|
||||||
|
required: true
|
||||||
|
default: true
|
||||||
|
|
||||||
|
# on:
|
||||||
|
# schedule:
|
||||||
|
# - cron: '*/5 * * * *' # 每5分钟一次,测试用
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bot:
|
||||||
|
runs-on: ubuntu-latest # 运行环境为最新版的Ubuntu
|
||||||
|
steps:
|
||||||
|
- name: 'Checkout codes' # 步骤一,获取仓库代码
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
# - name: 'Run baiduPush' # 步骤二,执行sh命令文件
|
||||||
|
# run: npm install && npm run baiduPush # 运行目录是仓库根目录
|
||||||
|
- name: Set up Python 3.8
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: 3.8
|
||||||
|
|
||||||
|
- name: install requests
|
||||||
|
run: pip install requests
|
||||||
|
|
||||||
|
- name: baidupush
|
||||||
|
run: npm run baidupush
|
||||||
18
baidupush.py
Normal file
18
baidupush.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import re
|
||||||
|
import ssl
|
||||||
|
import requests
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
ssl._create_default_https_context = ssl._create_unverified_context
|
||||||
|
parser = argparse.ArgumentParser(description='parse sitemap')
|
||||||
|
parser.add_argument('url', help='The url of your website')
|
||||||
|
args = parser.parse_args()
|
||||||
|
url = f'https://{args.url}/sitemap.xml'
|
||||||
|
result = requests.get(url)
|
||||||
|
big = re.findall('<loc>(.*?)</loc>', result.content.decode('utf-8'), re.S)
|
||||||
|
for i in big:
|
||||||
|
# print(i)
|
||||||
|
op_xml_txt = open('urls.txt', 'a')
|
||||||
|
op_xml_txt.write('%s\n' % i)
|
||||||
12
baidupush.sh
Normal file
12
baidupush.sh
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# 确保脚本抛出遇到的错误
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# 解析sitemap.xml, 记得换成你自己的域名,注意检查是否包含‘www’
|
||||||
|
python baidupush.py 'www.ghlerrix.cn'
|
||||||
|
|
||||||
|
# 百度链接推送,换成自己的token和域名
|
||||||
|
curl -H 'Content-Type:text/plain' --data-binary @urls.txt "http://data.zz.baidu.com/urls?site=https://www.ghlerrix.cn&token=oUldnU4HZvSTlh0e"
|
||||||
|
|
||||||
|
rm -rf urls.txt # 删除文件
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
"start": "next start",
|
"start": "next start",
|
||||||
"post-build": "next-sitemap --config next-sitemap.config.js",
|
"post-build": "next-sitemap --config next-sitemap.config.js",
|
||||||
"export": "next build && next-sitemap --config next-sitemap.config.js && next export",
|
"export": "next build && next-sitemap --config next-sitemap.config.js && next export",
|
||||||
"bundle-report": "ANALYZE=true yarn build"
|
"bundle-report": "ANALYZE=true yarn build",
|
||||||
|
"baidupush": "bash baidupush.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@giscus/react": "^2.2.6",
|
"@giscus/react": "^2.2.6",
|
||||||
|
|||||||
Reference in New Issue
Block a user