Skip to content

Commit e970796

Browse files
authored
Add files via upload
1 parent a9ab2d9 commit e970796

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

trackerslist.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import requests
2+
3+
# 要下载的文件链接列表
4+
urls = [
5+
"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt",
6+
"https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all_ip.txt",
7+
]
8+
9+
# 下载文件并保存到内存中
10+
def download_file(url):
11+
response = requests.get(url)
12+
return response.content
13+
14+
# 合并文件并去除空行
15+
def merge_files(contents):
16+
merged_content = ""
17+
for content in contents:
18+
lines = content.decode().split("\n")
19+
for line in lines:
20+
line = line.strip() # 去除首尾空格和换行符
21+
if line: # 如果不是空行则加入合并内容
22+
merged_content += line + "\n"
23+
return merged_content
24+
25+
# 下载文件并保存到内存中
26+
file_contents = []
27+
for url in urls:
28+
file_content = download_file(url)
29+
file_contents.append(file_content)
30+
31+
# 合并文件并去除空行
32+
merged_content = merge_files(file_contents)
33+
34+
# 保存合并结果到文件
35+
output_file = "trackerslist.txt"
36+
with open(output_file, "w") as file:
37+
file.write(merged_content)
38+
39+
print(f"文件已合并为 {output_file}")

0 commit comments

Comments
 (0)