python之正则匹配

日志格式如下:

115.245.164.176 - - [10/Mar/2015:10:57:29 +0800] "GET /s/0/8/20150226104330a393ea_com.tapinator.city.car.stunts3d_1.0.apk?sid=2afd95be-dd78-4136-802a-5f95a87be8f2&gid=534042&fz=37443420&t=0&pid=2&site=%E4%B9%9D%E6%B8%B8%E5%AE%89%E5%8D%93&pfid=139&ver=9.4.0.460&title=City%20Car%20Stunts%203D HTTP/1.1" 206 22065220 "http://www.9game.com/free-android-googleplay/" "UCWEB/2.0 (MIDP-2.0; U; Adr 4.2.2; null; iris402e) U2/1.0.0 UCBrowser/9.4.0.460 U2/1.0.0 Mobile" "-" 2854.663


mat=re.match(r'.*?\[(\d{2}/\w{2,10}/\d{4}:\d{2}:\d{2}:\d{2}).*?\].*?GET.*?sid=(\S{8,})&gid=(\d{1,})&fz=(\d+)&t=(\d*)&pid=', line)
re.match(r'.*?sid=.*?HTTP/\d+.\d+.*?(206|200).*?(\d+)', line)
re.match(r'.*?sid=.*?" (\d+.\d+)$', line)


你可能感兴趣的:(Python)