第二个脚本
import re
f = open("beijing1.txt", "r")
t = open("beijing2.txt", "w")
while True:
line = f.readline()
if line:
if 'np' in line and 'offline' in line :
m=re.split("[|]",line)
r1=r".*\?IMSI=(\d+)&MOBILE=&VERSION=(.*)&CHANNELID=(.*)"
s=re.search(r1,m[2])
if s:
s1=s.group(1)
s2=s.group(2)
s3=s.group(3)
w=m[0]+','+m[1]+','+'np'+','+s2+','+s1+','+s3+','+m[3]
t.write(w)
else:
break
f.close()
t.close()