-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate.py
36 lines (25 loc) · 1.02 KB
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
china_list_url = "https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf"
apple_list_url = "https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf"
out_file = "smartdns-domains.china.conf"
def fetch_and_extract_domains(url):
response = requests.get(url)
lines = response.text.splitlines()
domains = set()
for line in lines:
line = line.strip()
if line.startswith("server=/"):
domain = line.split("/")[1]
domains.add(domain)
return domains
def write_domains_to_file(domains, file_path):
with open(file_path, "w") as f:
for domain in sorted(domains):
f.write(domain + "\n")
def main():
china_domains = fetch_and_extract_domains(china_list_url)
apple_domains = fetch_and_extract_domains(apple_list_url)
all_domains = china_domains.union(apple_domains)
write_domains_to_file(all_domains, out_file)
if __name__ == "__main__":
main()