scitex_scholar.browser

class scitex_scholar.browser.ScholarBrowserManager(browser_mode=None, auth_manager=None, chrome_profile_name=None, config=None)[source]

Bases: BrowserMixin

Manages a local browser instance with stealth enhancements and invisible mode.

__init__(browser_mode=None, auth_manager=None, chrome_profile_name=None, config=None)[source]

Initialize ScholarBrowserManager with invisible browser capabilities.

Parameters:
  • auth_manager – Authentication manager instance

  • config (ScholarConfig) – Scholar configuration instance

async get_authenticated_browser_and_context_async(**context_options)[source]

Get browser context with authentication cookies and extensions loaded.

Return type:

tuple[Browser, BrowserContext]

async _new_context_async(browser, **context_options)[source]

Creates a new browser context with stealth options and invisible mode applied.

Return type:

BrowserContext

_verify_xvfb_running(_recursed=False)[source]

Verify Xvfb virtual display is running; auto-start if absent.

async _load_auth_cookies_to_persistent_context_async()[source]

Load authentication cookies into the persistent browser context.

async take_screenshot_async(page, path, timeout_sec=30.0, timeout_after_sec=30.0, full_page=False)[source]

Take screenshot without viewport changes.

async start_periodic_screenshots_async(page, output_dir, prefix='periodic', interval_seconds=1, duration_seconds=10, verbose=False)[source]

Start taking periodic screenshots in the background.

Parameters:
  • page – The page to screenshot

  • prefix (str) – Prefix for screenshot filenames

  • interval_seconds (int) – Seconds between screenshots

  • duration_seconds (int) – Total duration to take screenshots (0 = infinite)

  • verbose (bool) – Whether to log each screenshot

Returns:

asyncio.Task that can be cancelled to stop screenshots

async stop_periodic_screenshots_async(task)[source]

Stop periodic screenshots task.

async close()[source]

Close browser while preserving authentication and extension data.