From 667d6acbd6aa48f0a4a1d26f4fc8981a12972580 Mon Sep 17 00:00:00 2001 From: rootmelo92118 <32770959+rootmelo92118@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:45:28 +0800 Subject: [PATCH 01/11] Create twnic_rpz_1.0.py --- AutoBuild/twnic_rpz_1.0.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 AutoBuild/twnic_rpz_1.0.py diff --git a/AutoBuild/twnic_rpz_1.0.py b/AutoBuild/twnic_rpz_1.0.py new file mode 100644 index 0000000..4566e83 --- /dev/null +++ b/AutoBuild/twnic_rpz_1.0.py @@ -0,0 +1,17 @@ +import requests, json +from bs4 import BeautifulSoup + +soup = BeautifulSoup(requests.get("https://rpz.twnic.tw/e.html").text, "html.parser") +exec(str(soup.find("script")).split(";")[0].split("const ")[1]) +twnic_rpz_1_0_raw = "" +twnic_rpz_1_0_AdGuardHome = "" +for i in rpzdata: + for datap in i["domains"]: + twnic_rpz_1_0_raw += datap + "\n" + twnic_rpz_1_0_AdGuardHome += "||" + datap + "^\n" +with open("twnicRPZ1.0RAW.txt","a") as f: + f.write(twnic_rpz_1_0_raw) + f.close() +with open("twnicRPZ1.0AGH.txt","a") as f: + f.write(twnic_rpz_1_0_AdGuardHome) + f.close() From 6354102b4aeb0f231506672a5d8c57d19e986656 Mon Sep 17 00:00:00 2001 From: rootmelo92118 <32770959+rootmelo92118@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:48:41 +0800 Subject: [PATCH 02/11] Update requirements.txt --- AutoBuild/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/AutoBuild/requirements.txt b/AutoBuild/requirements.txt index feb5e82..e7bc71d 100644 --- a/AutoBuild/requirements.txt +++ b/AutoBuild/requirements.txt @@ -3,3 +3,4 @@ charset-normalizer==2.1.1 idna==3.3 requests==2.28.1 urllib3==1.26.12 +bs4==0.0.1 From 7b9f17ea1d8b531765521c75167b42b8b715a97b Mon Sep 17 00:00:00 2001 From: rootmelo92118 <32770959+rootmelo92118@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:54:27 +0800 Subject: [PATCH 03/11] Create twnic_rpz_1.0.yml --- .github/workflows/twnic_rpz_1.0.yml | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/twnic_rpz_1.0.yml diff --git a/.github/workflows/twnic_rpz_1.0.yml b/.github/workflows/twnic_rpz_1.0.yml new file mode 100644 index 0000000..a477940 --- /dev/null +++ b/.github/workflows/twnic_rpz_1.0.yml @@ -0,0 +1,30 @@ +name: TWNIC RPZ 1.0 + +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + +jobs: + update_165_data: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + cache: 'pip' # caching pip dependencies + - run: pip install -r AutoBuild/requirements.txt && python AutoBuild/twnic_rpz_1.0.py + env: + tw165json: ${{ vars.TW165JSON }} + tw165csv: ${{ vars.TW165CSV }} + auth: ${{ secrets.AUTH }} + - name: push + uses: github-actions-x/commit@v2.9 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + push-branch: 'master' + commit-message: '🤖 自動更新 TWNIC RPZ 1.0 封鎖域名' + files: TWNIC-RPZ-1.0_RAW.txt TWNIC-RPZ-1.0_AGH.txt + name: tdc + email: tdc@sudo.host From 97cd7759efc5c095d627ebe86b91d86766332694 Mon Sep 17 00:00:00 2001 From: rootmelo92118 <32770959+rootmelo92118@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:54:56 +0800 Subject: [PATCH 04/11] Update twnic_rpz_1.0.py --- AutoBuild/twnic_rpz_1.0.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AutoBuild/twnic_rpz_1.0.py b/AutoBuild/twnic_rpz_1.0.py index 4566e83..55f91c7 100644 --- a/AutoBuild/twnic_rpz_1.0.py +++ b/AutoBuild/twnic_rpz_1.0.py @@ -9,9 +9,9 @@ for i in rpzdata: for datap in i["domains"]: twnic_rpz_1_0_raw += datap + "\n" twnic_rpz_1_0_AdGuardHome += "||" + datap + "^\n" -with open("twnicRPZ1.0RAW.txt","a") as f: +with open("TWNIC-RPZ-1.0_RAW.txt","a") as f: f.write(twnic_rpz_1_0_raw) f.close() -with open("twnicRPZ1.0AGH.txt","a") as f: +with open("TWNIC-RPZ-1.0_AGH.txt","a") as f: f.write(twnic_rpz_1_0_AdGuardHome) f.close() From 6b235e5bbc4ab2d2dfec846e853b438964a0e0e0 Mon Sep 17 00:00:00 2001 From: rootmelo92118 <32770959+rootmelo92118@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:34:48 +0800 Subject: [PATCH 05/11] Update twnic_rpz_1.0.py --- AutoBuild/twnic_rpz_1.0.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AutoBuild/twnic_rpz_1.0.py b/AutoBuild/twnic_rpz_1.0.py index 55f91c7..6400b67 100644 --- a/AutoBuild/twnic_rpz_1.0.py +++ b/AutoBuild/twnic_rpz_1.0.py @@ -9,9 +9,9 @@ for i in rpzdata: for datap in i["domains"]: twnic_rpz_1_0_raw += datap + "\n" twnic_rpz_1_0_AdGuardHome += "||" + datap + "^\n" -with open("TWNIC-RPZ-1.0_RAW.txt","a") as f: +with open("TWNIC-RPZ-1.0_RAW.txt","w") as f: f.write(twnic_rpz_1_0_raw) f.close() -with open("TWNIC-RPZ-1.0_AGH.txt","a") as f: +with open("TWNIC-RPZ-1.0_AGH.txt","w") as f: f.write(twnic_rpz_1_0_AdGuardHome) f.close() From 4b6b7bc2ce8518545e1adc92960dc79373bcfed3 Mon Sep 17 00:00:00 2001 From: rootmelo92118 <32770959+rootmelo92118@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:41:37 +0800 Subject: [PATCH 06/11] Update twnic_rpz_1.0.py --- AutoBuild/twnic_rpz_1.0.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/AutoBuild/twnic_rpz_1.0.py b/AutoBuild/twnic_rpz_1.0.py index 6400b67..91876b0 100644 --- a/AutoBuild/twnic_rpz_1.0.py +++ b/AutoBuild/twnic_rpz_1.0.py @@ -11,7 +11,5 @@ for i in rpzdata: twnic_rpz_1_0_AdGuardHome += "||" + datap + "^\n" with open("TWNIC-RPZ-1.0_RAW.txt","w") as f: f.write(twnic_rpz_1_0_raw) - f.close() with open("TWNIC-RPZ-1.0_AGH.txt","w") as f: f.write(twnic_rpz_1_0_AdGuardHome) - f.close() From 07623225b4223d5aab9b24bda32d6fd4e8cd18a8 Mon Sep 17 00:00:00 2001 From: rootmelo92118 <32770959+rootmelo92118@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:50:26 +0800 Subject: [PATCH 07/11] Update twnic_rpz_1.0.py --- AutoBuild/twnic_rpz_1.0.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AutoBuild/twnic_rpz_1.0.py b/AutoBuild/twnic_rpz_1.0.py index 91876b0..1fdd498 100644 --- a/AutoBuild/twnic_rpz_1.0.py +++ b/AutoBuild/twnic_rpz_1.0.py @@ -1,8 +1,8 @@ import requests, json from bs4 import BeautifulSoup -soup = BeautifulSoup(requests.get("https://rpz.twnic.tw/e.html").text, "html.parser") -exec(str(soup.find("script")).split(";")[0].split("const ")[1]) +rawData = BeautifulSoup(requests.get("https://rpz.twnic.tw/e.html").text, "html.parser") +rpzdata = json.loads(a.split("