back to table · edit · history · where entries came from · files · download
3185 bytes, as of the version from 2026-11-18 01:45 (current). Recorded here, not run.
"""Inspect freshly downloaded authenticated HTML without sending credentials to Chromium."""
import os,sys,json,hashlib,collections,importlib.metadata
from pathlib import Path
from playwright.sync_api import sync_playwright
w=Path(os.environ['TMPDIR']); phase=sys.argv[1]
assert phase in ('before','after')
html=w/(phase+'-page.html')
with sync_playwright() as p:
b=p.chromium.launch(headless=True,args=['--no-sandbox'])
page=b.new_page(viewport={'width':1440,'height':1100})
page.route('https://numberdb.org/T741',lambda route:route.fulfill(status=200,content_type='text/html',body=html.read_bytes()))
page.goto('https://numberdb.org/T741',wait_until='domcontentloaded',timeout=45000)
page.wait_for_timeout(3500)
key='normalization' if phase=='before' else 'period-conversion'
cite=page.locator('a.CITE[href="#'+key+'"]').first
target=cite.evaluate('el => {const t=document.getElementById(el.hash.slice(1)); return {anchor:el.hash,text:el.textContent,target_text:t.innerText,target_html:t.outerHTML,target_top:t.getBoundingClientRect().top+scrollY}}')
cite.click();page.wait_for_timeout(400)
target['scroll_after_click']=page.evaluate('scrollY')
ids=page.locator('[id]').evaluate_all('es=>es.map(e=>e.id)')
out={'versions':{'playwright':importlib.metadata.version('playwright'),'chromium':b.version},'phase':phase,'method':'Fresh authenticated server HTML replayed at its original URL; public resources loaded without bot credentials','page_sha256':hashlib.sha256(html.read_bytes()).hexdigest(),'duplicates':{k:v for k,v in collections.Counter(ids).items() if v>1},'normalization_count':ids.count('normalization'),'period_conversion_count':ids.count('period-conversion'),'citation':target,'sections':page.locator('.table-section-title').all_text_contents(),'rows':[x for x in ids if x.count(',')==2 and x.endswith(('bessel','period'))],'math_errors':page.locator('mjx-merror,.katex-error,[data-mjx-error]').all_text_contents(),'math_containers':page.locator('mjx-container').count()}
out['citations']=page.locator('a.CITE').evaluate_all('(es)=>es.map(e=>({href:e.getAttribute("href"),matches:[...document.querySelectorAll("[id]")].filter(t=>t.id===e.hash.slice(1)).length}))')
if phase=='after': assert all(x['matches']==1 for x in out['citations'])
for summary in page.locator('details.prose-more > summary').all(): summary.click()
out['expanded_rigour_details']=page.locator('details.prose-more[open]').count()
(w/(phase+'-render.txt')).write_text(page.locator('body').inner_text())
(w/(phase+'-render.html')).write_text(page.content())
page.screenshot(path=str(w/(phase+'-render.png')),full_page=True)
(w/(phase+'-browser-results.json')).write_text(json.dumps(out,indent=2)+'\n')
assert len(out['rows'])==20 and not out['math_errors']
if phase=='before':
assert out['normalization_count']==2 and out['period_conversion_count']==0
assert 'moment normalization' in target['target_text']
else:
assert out['normalization_count']==1 and out['period_conversion_count']==1
assert 'inverse conversion' in target['target_text'] and 'moment normalization' not in target['target_text']
assert not out['duplicates']
print(json.dumps(out,indent=2))
b.close()