back to table · edit · history · where entries came from · files · download
986 bytes, as of the version from 2026-11-26 11:20 (current). Recorded here, not run.
import os,json,urllib.parse
from html.parser import HTMLParser
from pathlib import Path
w=Path(os.environ['NUMBERDB_WORKDIR'])
class Links(HTMLParser):
def __init__(self):super().__init__();self.links=[]
def handle_starttag(self,tag,attrs):
d=dict(attrs)
if tag=='a' and 'HREF' in d.get('class','').split():self.links.append(d.get('href'))
p=Links();p.feed((w/'preview-3.html').read_text())
resolved=[urllib.parse.urljoin('https://numberdb.org/preview',h) for h in p.links]
result={'links':resolved,'all_intended_relations_rendered':all('https://numberdb.org/'+tid in resolved for tid in ['T99','T816']),'note':'The renderer writes href=T99 and href=T816 without a leading slash; these resolve correctly against /preview and /Classical_q-Lommel_polynomials. The earlier browser selector looked only for leading-slash attributes.'}
(w/'rendered-links-results.json').write_text(json.dumps(result,indent=2));print(json.dumps(result));assert result['all_intended_relations_rendered']