Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Commit

Permalink
提取 ip_tmpok 时去重
Browse files Browse the repository at this point in the history
  • Loading branch information
xyuanmu@gmail.com committed Oct 26, 2015
1 parent 13604a3 commit dad8352
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ip_bind.txt
ip_json.txt
ip_tmp*
18 changes: 11 additions & 7 deletions bindip.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@

import os

iplist = []

if os.path.exists('ip_tmpok.txt'):
line_list = []
ip_list = []
new_line_list = []
with open('ip_tmpok.txt') as ip_tmpok:
for x in ip_tmpok:
sline = x.strip().split(' ')
iplist.append(sline)
if sline[1].startswith("NA_"):
sline[1] = sline[1].lstrip('NA_')
if sline[1].startswith("NA_"): sline[1] = sline[1].lstrip('NA_')
line_list.append(sline)
line_list.sort(key=lambda x: int(x[1]))
for line in line_list:
if line[0] not in ip_list:
ip_list.append(line[0])
new_line_list.append(line)
with open('ip_bind.txt', 'w') as ip_bind:
iplist.sort(key=lambda x: int(x[1]))
out = '|'.join(x[0] for x in iplist if int(x[1]) < 3000) # 默认抽取3000ms以内IP,可自行修改
out = '|'.join(x[0] for x in new_line_list if int(x[1]) < 2000) # 默认抽取2000ms以内IP,可自行修改
print(out)
# print(iplist)
ip_bind.write(out)
Expand Down
18 changes: 11 additions & 7 deletions bindip_json.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@

import os

iplist = []

if os.path.exists('ip_tmpok.txt'):
line_list = []
ip_list = []
new_line_list = []
with open('ip_tmpok.txt') as ip_tmpok:
for x in ip_tmpok:
sline = x.strip().split(' ')
iplist.append(sline)
if sline[1].startswith("NA_"):
sline[1] = sline[1].lstrip('NA_')
if sline[1].startswith("NA_"): sline[1] = sline[1].lstrip('NA_')
line_list.append(sline)
line_list.sort(key=lambda x: int(x[1]))
for line in line_list:
if line[0] not in ip_list:
ip_list.append(line[0])
new_line_list.append(line)
with open('ip_json.txt', 'w') as ip_bind:
iplist.sort(key=lambda x: int(x[1]))
out = '"'+'", "'.join(x[0] for x in iplist if int(x[1]) < 3000)+'"' # 默认抽取3000ms以内IP,可自行修改
out = '"'+'", "'.join(x[0] for x in new_line_list if int(x[1]) < 2000)+'"' # 默认抽取2000ms以内IP,可自行修改
print(out)
# print(iplist)
ip_bind.write(out)
Expand Down

0 comments on commit dad8352

Please sign in to comment.