back to table · edit · history · where entries came from · files · download
2889 bytes, as of the version from 2026-11-26 11:20 (current). Recorded here, not run.
import json,os,re
from pathlib import Path
from playwright.sync_api import sync_playwright
w=Path(os.environ['NUMBERDB_WORKDIR']);requests=json.loads((w/'preview-requests.json').read_text())
results={'table':'T817','mode':'site-rendered previews of exact stored sections; actual draft page requires session login','actual_page_status':404,'parts':[],'limitations':['No signed-in website session is supplied. The API key was used only on NumberDB API requests. Full-document preview exceeds proxy URI limits; exact stored sections were previewed separately using the same site renderer.']}
with sync_playwright() as p:
browser=p.chromium.launch(headless=True)
context=browser.new_context(viewport={'width':1440,'height':1050},device_scale_factor=1)
page=context.new_page()
for request in requests:
if 'part' not in request:continue
i=request['part'];html=(w/f'preview-{i}.html').read_text();url=request['url']
# Render the captured live server response; no credentials enter the browser.
page.route(url,lambda route,request,body=html:route.fulfill(status=200,content_type='text/html',body=body))
page.goto(url,wait_until='networkidle',timeout=30000)
page.wait_for_function("document.querySelector('mjx-container') !== null || document.querySelector('.MathJax') !== null", timeout=15000)
page.evaluate("async () => { if (window.MathJax && MathJax.startup && MathJax.startup.promise) await MathJax.startup.promise; }")
page.locator('#preview-header').scroll_into_view_if_needed()
text=page.locator('body').inner_text()
math_errors=page.locator('.katex-error, mjx-merror, [data-mjx-error]').all_text_contents()
math_nodes=page.locator('mjx-container, .MathJax').count()
links=page.locator('a[href]').evaluate_all('(links)=>links.map(a=>({text:a.innerText,href:a.getAttribute("href")}))')
entry={'part':i,'sections':request['sections'],'math_errors':math_errors,'math_nodes':math_nodes,'links':[l for l in links if l['href'] in ['/T99','/T816'] or 'arxiv' in l['href']],'contains_title':'Classical q-Lommel polynomials' in text}
if 'Similar tables' in request['sections']:
entry['similar_heading']='Similar tables' in text
entry['relations_visible']=all(s in text for s in ['Chebyshev polynomials of the second kind','Lommel polynomials','scaled limit differs'])
entry['relation_links']=[l for l in links if l['href'] in ['/T99','/T816']]
(w/f'preview-{i}-visible.txt').write_text(text)
page.screenshot(path=str(w/f'preview-{i}.png'),full_page=True)
results['parts'].append(entry)
browser.close()
results['all_math_rendered']=all(not p['math_errors'] for p in results['parts'])
(w/'browser-results.json').write_text(json.dumps(results,indent=2))
print(json.dumps(results,indent=2))
assert results['all_math_rendered']
assert all(p['contains_title'] for p in results['parts'])
assert all(p.get('relations_visible',True) for p in results['parts'])