sort
This commit is contained in:
parent
b4f18acecd
commit
cb77afbb29
10
README.md
10
README.md
|
|
@ -1,7 +1,15 @@
|
||||||
# ban-pcdn-ip
|
# ban-pcdn-ip
|
||||||
收集地区为山西、运营商为联通的PCDN恶意刷量IP段清单。
|
收集地区为山西、运营商为联通的PCDN恶意刷量IP段清单。
|
||||||
|
|
||||||
情况介绍部分链接:
|
|
||||||
|
## ip清单
|
||||||
|
ipdb.txt文件,已经排序。
|
||||||
|
|
||||||
|
## main.py
|
||||||
|
用来对ipdb.txt进行排序的脚本,可以忽略。
|
||||||
|
|
||||||
|
|
||||||
|
## 情况介绍部分链接:
|
||||||
|
|
||||||
https://www.v2ex.com/t/1056361
|
https://www.v2ex.com/t/1056361
|
||||||
|
|
||||||
|
|
|
||||||
1
ipdb.txt
1
ipdb.txt
|
|
@ -1,3 +1,4 @@
|
||||||
|
# IP段清单
|
||||||
104.247.192.0/24
|
104.247.192.0/24
|
||||||
104.247.192.0/24
|
104.247.192.0/24
|
||||||
107.149.204.0/24
|
107.149.204.0/24
|
||||||
|
|
|
||||||
7
main.py
7
main.py
|
|
@ -15,10 +15,15 @@ with open('ipdb.txt', 'r') as f:
|
||||||
# 读取内容,并将每行的数据进行排序
|
# 读取内容,并将每行的数据进行排序
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
lines_without_newlines = [line.strip() for line in lines]
|
lines_without_newlines = [line.strip() for line in lines]
|
||||||
|
# 剔除lines_without_newlines中空的元素和#开头的元素
|
||||||
|
lines_without_newlines = [line for line in lines_without_newlines if line and not line.startswith('#')]
|
||||||
#print(lines_without_newlines)
|
#print(lines_without_newlines)
|
||||||
lines_without_newlines.sort()
|
lines_without_newlines.sort()
|
||||||
|
# 在lines_without_newlines开头插入新元素
|
||||||
|
lines_without_newlines.insert(0, '# IP段清单')
|
||||||
#print(lines_without_newlines)
|
#print(lines_without_newlines)
|
||||||
# 将排序后的内容写入文件,要求每个元素一行
|
# 将排序后的内容写入文件,要求每个元素一行
|
||||||
with open('ipdb.txt', 'w') as f:
|
with open('ipdb.txt', 'w') as f:
|
||||||
f.write('\n'.join(lines_without_newlines))
|
f.write('\n'.join(lines_without_newlines))
|
||||||
print('排序完成!')
|
print('排序完成,更新完成!')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue