comparison workers/bin/_timedWhich.py @ 40:4cf6bc21f683

start work on python version of tW.sh
author Henry S. Thompson <ht@markup.co.uk>
date Fri, 30 Nov 2018 13:43:36 +0000
parents
children 1d776e96c16a
comparison
equal deleted inserted replaced
39:bb09db2afe6b 40:4cf6bc21f683
1 #!/usr/bin/env python3
2 import re,sys,io
3
4 uin=io.TextIOWrapper(sys.stdin.buffer,encoding='latin1')
5 p1=re.compile('"WARC-Target-URI":"(https?):.*msgtype=response')
6 p2=re.compile('"Last-Modified":"([^"]*)"')
7 w={}
8 wo={}
9 for l in uin:
10 m=p1.search(l)
11 if m:
12 k=m.group(1)
13 m=p2.search(l,m.end())
14 if m is None:
15 wo[k]=wo.get(k,0)+1
16 else:
17 w[k]=w.get(k,0)+1
18 print("with %s\nw/o %s"%(w,wo))