This commit is contained in:
Binary file not shown.
@@ -55,6 +55,22 @@ async def visit_url_service(decoded_url):
|
||||
# Perform the operation
|
||||
return await safe_browser_operation(decoded_url, visit_operation)
|
||||
|
||||
async def screenshot_url_service(decoded_url, full_page=True):
|
||||
"""Service function to visit a URL and return a screenshot as PNG bytes"""
|
||||
print(f"Taking screenshot of: {decoded_url}")
|
||||
|
||||
async def screenshot_operation(page):
|
||||
try:
|
||||
await page.goto(decoded_url, wait_until='networkidle', timeout=30000)
|
||||
await page.wait_for_timeout(1000)
|
||||
screenshot_bytes = await page.screenshot(full_page=full_page, type='png')
|
||||
return screenshot_bytes
|
||||
except Exception as e:
|
||||
print(f"Error during screenshot capture: {e}")
|
||||
return {"status": "error", "url": decoded_url, "error": str(e)}
|
||||
|
||||
return await safe_browser_operation(decoded_url, screenshot_operation)
|
||||
|
||||
async def extract_seo_service(decoded_url):
|
||||
"""Service function to extract SEO information from a website"""
|
||||
print(f"Extracting SEO from: {decoded_url}")
|
||||
|
||||
Reference in New Issue
Block a user