第二个脚本

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()

posted @ 2013-12-04 16:04  沙漠里的小鱼  阅读(106)  评论(0编辑  收藏  举报