Capture Components¶
The capture module provides screenshot capture capabilities for web pages and batch processing of multiple URLs.
Capture¶
- class layoutlens.capture.Capture(output_dir='screenshots', timeout=30000)[source]¶
Bases:
objectSimple screenshot capture system using Playwright.
One method handles everything - single URLs are just lists of 1 item.
- VIEWPORTS = {'desktop': ViewportConfig(name='desktop', width=1920, height=1080, device_scale_factor=1.0, is_mobile=False, has_touch=False, user_agent=None), 'laptop': ViewportConfig(name='laptop', width=1366, height=768, device_scale_factor=1.0, is_mobile=False, has_touch=False, user_agent=None), 'mobile': ViewportConfig(name='mobile', width=375, height=667, device_scale_factor=2.0, is_mobile=True, has_touch=True, user_agent=None), 'mobile_landscape': ViewportConfig(name='mobile_landscape', width=667, height=375, device_scale_factor=2.0, is_mobile=True, has_touch=True, user_agent=None), 'mobile_portrait': ViewportConfig(name='mobile_portrait', width=375, height=667, device_scale_factor=2.0, is_mobile=True, has_touch=True, user_agent=None), 'tablet': ViewportConfig(name='tablet', width=768, height=1024, device_scale_factor=2.0, is_mobile=True, has_touch=True, user_agent=None)}¶
- async screenshots(urls, viewport='desktop', max_concurrent=3, wait_for_selector=None, wait_time=None)[source]¶
Capture screenshots from URLs.
Simple interface: give it URLs, get back screenshot paths. Single URL? Pass a list with 1 item. Multiple URLs? Pass a list.
- Parameters:
- Returns:
List of screenshot paths in same order as input URLs
- Return type:
Examples
# Single URL paths = await capture.screenshots([”https://example.com”]) # Returns: [“/path/to/screenshot.png”]
# Multiple URLs paths = await capture.screenshots([“url1”, “url2”]) # Returns: [“/path1.png”, “/path2.png”]