From 5d768f940df694cefc4b2c63bce8eeeae7515e2b Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 28 Sep 2022 20:13:02 +0800 Subject: [PATCH] feat: chinalist fetch --- assets/chinalist.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 assets/chinalist.py diff --git a/assets/chinalist.py b/assets/chinalist.py new file mode 100755 index 0000000..c27588a --- /dev/null +++ b/assets/chinalist.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import re + +source = [ + 'curl -sL https://github.com/felixonmars/dnsmasq-china-list/raw/master/accelerated-domains.china.conf' + ' | sed \'/^#/d\' | sed \'s/server=\\///g;s/\\/114.114.114.114//g\'', + 'curl -sL https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/direct-list.txt' + ' | grep -v \':\'', + 'curl -sL https://github.com/hq450/fancyss/raw/master/rules/WhiteList_new.txt' + ' | sed \'s/Server=\\///g;s/\\///g\'', +] + +domains = set() +for script in source: + raw = os.popen(script).read().split('\n') + domains.update(filter(None, raw)) +regex = r'^(?=^.{3,255}$)[a-zA-Z0-9][a-zA-Z0-9\-]{0,62}(.[a-zA-Z0-9][a-zA-Z0-9\-]{0,62})+$' +domains = {x for x in domains if re.search(regex, str(x)) is not None} +print('\n'.join(sorted(domains)))