Screenshot backfill: query content_length for dynamic delay
This commit is contained in:
parent
5228f21675
commit
3fa3c9722b
1 changed files with 12 additions and 1 deletions
13
neopig.py
13
neopig.py
|
|
@ -932,7 +932,18 @@ class NeoPig:
|
||||||
async def capture_one(page_uri: str):
|
async def capture_one(page_uri: str):
|
||||||
async with semaphore:
|
async with semaphore:
|
||||||
try:
|
try:
|
||||||
await self._capture_page_screenshot(page_uri, crawl_job_id or 0, content_length=0)
|
# Get content length for dynamic delay
|
||||||
|
content_length = 0
|
||||||
|
async with aiosqlite.connect(db_path) as conn:
|
||||||
|
cursor = await conn.execute(
|
||||||
|
"SELECT LENGTH(raw_html) FROM pages WHERE uri = ?",
|
||||||
|
(page_uri,)
|
||||||
|
)
|
||||||
|
row = await cursor.fetchone()
|
||||||
|
if row and row[0]:
|
||||||
|
content_length = row[0]
|
||||||
|
|
||||||
|
await self._capture_page_screenshot(page_uri, crawl_job_id or 0, content_length=content_length)
|
||||||
# Check if screenshot was actually captured (added to seen_screenshots)
|
# Check if screenshot was actually captured (added to seen_screenshots)
|
||||||
success = page_uri in self.seen_screenshots
|
success = page_uri in self.seen_screenshots
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue