import re,html,sys,glob,os out=open('reference/scratch/t386.txt','w') stats={} for f in sorted(glob.glob('reference/spritesmind/t386-*.html')): s=open(f,encoding='utf-8',errors='replace').read() posts=re.split(r'
]*>([^<]+)<',body) dt=re.search(r'
\s*(?:
\s*
\s*
\s*
.*?','\n[CODE]\n',txt,flags=re.S); txt=txt.replace('','\n[/CODE]\n') txt=re.sub(r']*src="([^"]+)"[^>]*>',r'[IMG \1]',txt) txt=re.sub(r']*href="([^"]+)"[^>]*>(.*?)',r'\2 <\1>',txt,flags=re.S) txt=html.unescape(re.sub(r'<[^>]+>','',txt)) a=au.group(1) if au else '?' stats[a]=stats.get(a,0)+len(txt) out.write(f"\n\n######## POST p{pid} | {a} | {dt.group(1)[:10] if dt else '?'} | {os.path.basename(f)}\n{txt.strip()}\n") out.close() for a,n in sorted(stats.items(),key=lambda x:-x[1])[:30]: print(a,n)