From 770382afb54839eae033c1d26edeb47be4672966 Mon Sep 17 00:00:00 2001 From: Ghlerrix Date: Mon, 7 Aug 2023 14:51:20 +0800 Subject: [PATCH] test action and parse --- .github/workflows/baidupush.yml | 29 +++++++++++++++++++++++++++++ baidupush.py | 11 +++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/baidupush.yml create mode 100644 baidupush.py diff --git a/.github/workflows/baidupush.yml b/.github/workflows/baidupush.yml new file mode 100644 index 00000000..7a13ab1f --- /dev/null +++ b/.github/workflows/baidupush.yml @@ -0,0 +1,29 @@ +## 利用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 + +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: parse sitemap + run: python baidupush.py \ No newline at end of file diff --git a/baidupush.py b/baidupush.py new file mode 100644 index 00000000..8906bf21 --- /dev/null +++ b/baidupush.py @@ -0,0 +1,11 @@ +import re +import ssl +import requests +ssl._create_default_https_context = ssl._create_unverified_context +url = 'https://www.ghlerrix.cn/sitemap.xml' +result = requests.get(url) +big = re.findall('(.*?)', result.content.decode('utf-8'), re.S) +for i in big: + print(i) + # op_xml_txt = open('xml.txt', 'a') + # op_xml_txt.write('%s\n' % i)