(raw_html: str, url: str)
| 493 | |
| 494 | |
| 495 | def reader_html(raw_html: str, url: str) -> str: |
| 496 | title = page_title_from_html(raw_html, url) |
| 497 | text = TEXT_CLEAN_RE.sub(" ", raw_html) |
| 498 | text = re.sub(r'\s+', ' ', text).strip() |
| 499 | paras = [text[i:i+1200] for i in range(0, len(text), 1200)] or ["No readable text found."] |
| 500 | blocks = "".join(f"<p style='line-height:1.7;margin:0 0 16px 0;'>{html.escape(p)}</p>" for p in paras[:30]) |
| 501 | return f""" |
| 502 | <html><head><meta name='viewport' content='width=device-width,initial-scale=1'><title>{html.escape(title)}</title></head> |
| 503 | <body style='margin:0;background:#06040b;color:#f4edff;font-family:system-ui,sans-serif;'> |
| 504 | <div style='max-width:900px;margin:0 auto;padding:18px;'> |
| 505 | <div style='position:sticky;top:0;background:#06040b;padding:10px 0 18px;border-bottom:1px solid #5c3e82;margin-bottom:18px;'> |
| 506 | <a href='{url_for('browser_open')}?url={urllib.parse.quote(url, safe='')}' style='color:#d7a6ff;text-decoration:none;'>← Back</a> |
| 507 | <h1 style='margin:12px 0 0;font-size:24px;'>{html.escape(title)}</h1> |
| 508 | <div style='font-size:13px;opacity:.75;word-break:break-all;'>{html.escape(url)}</div> |
| 509 | </div> |
| 510 | {blocks} |
| 511 | </div></body></html> |
| 512 | """ |
| 513 | |
| 514 | |
| 515 | def fetch_proxies_from_proxyscrape_v4(country: str) -> List[str]: |
no test coverage detected