ticket #104 attempt 1
This commit is contained in:
parent
ad1736ebf1
commit
a0d573375a
@ -22,6 +22,8 @@ from .pdf import MAX_PDF_BYTES, extract_pdf_text, is_pdf
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
_pw_lock = asyncio.Lock()
|
||||||
|
|
||||||
RSEARCH_URL = "https://rsearch.app.molodetz.nl"
|
RSEARCH_URL = "https://rsearch.app.molodetz.nl"
|
||||||
RSEARCH_TIMEOUT_SECONDS = 45.0
|
RSEARCH_TIMEOUT_SECONDS = 45.0
|
||||||
FETCH_TIMEOUT_SECONDS = 20.0
|
FETCH_TIMEOUT_SECONDS = 20.0
|
||||||
@ -242,18 +244,20 @@ async def fetch_page(url: str, depth: int, browser=None) -> CrawledPage | None:
|
|||||||
except (LookupError, ValueError) as exc:
|
except (LookupError, ValueError) as exc:
|
||||||
logger.info("deepsearch decode failed for %s: %s", url, exc)
|
logger.info("deepsearch decode failed for %s: %s", url, exc)
|
||||||
if len(text) < MIN_PAGE_CHARS:
|
if len(text) < MIN_PAGE_CHARS:
|
||||||
try:
|
async with _pw_lock:
|
||||||
r_title, r_text, r_status, r_links = await _render_with_playwright(url, browser)
|
try:
|
||||||
if len(r_text) > len(text):
|
r_title, r_text, r_status, r_links = await _render_with_playwright(url, browser)
|
||||||
title, text, status, source, links = (
|
except Exception as exc:
|
||||||
r_title or title,
|
logger.info("deepsearch render failed for %s: %s", url, exc)
|
||||||
r_text,
|
r_title, r_text, r_status, r_links = "", "", 0, []
|
||||||
r_status or status,
|
if len(r_text) > len(text):
|
||||||
"playwright",
|
title, text, status, source, links = (
|
||||||
r_links,
|
r_title or title,
|
||||||
)
|
r_text,
|
||||||
except Exception as exc:
|
r_status or status,
|
||||||
logger.info("deepsearch render failed for %s: %s", url, exc)
|
"playwright",
|
||||||
|
r_links,
|
||||||
|
)
|
||||||
if len(text) < MIN_PAGE_CHARS:
|
if len(text) < MIN_PAGE_CHARS:
|
||||||
return None
|
return None
|
||||||
return CrawledPage(
|
return CrawledPage(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user