scitex_browser.core
Core browser management components.
- class scitex_browser.core.BrowserMixin(mode)[source]
Bases:
objectMixin for local browser-based strategies with common functionality.
Browser Modes: - interactive: For human interaction (authentication, debugging) - 1280x720 viewport - stealth: For automated operations (scraping, downloading) - 1x1 viewport
Note: Always runs browser in visible system mode (never truly headless) but uses viewport sizing to control interaction vs stealth behavior.
- __init__(mode)[source]
Initialize browser mixin.
- Parameters:
mode – Browser mode - ‘interactive’ or ‘stealth’
Get or create shared browser instance (deprecated - use get_browser_async).
- Return type:
Browser
Clean up shared browser instance (call on app shutdown).
- async get_browser_async()[source]
Get or create a local browser instance with the current mode setting.
- Return type:
Browser
- async create_browser_context_async(playwright_instance, **context_options)[source]
Create browser context with cookie auto-acceptance.
- async get_session_async(timeout=30)[source]
Get or create basic aiohttp session.
- Return type:
ClientSession
- async accept_cookies_async(page_index=0, wait_seconds=2)[source]
Manually accept cookies on specific page.
- class scitex_browser.core.ChromeProfileManager(profile_name, chrome_cache_dir=None, config=None)[source]
Bases:
objectManages Chrome profile especially extensions for automated literature search.
- EXTENSIONS = {'2captcha_solver': {'id': 'ifibfemgeogfhoebkmokieepdoobkbpo', 'name': '2Captcha Solver'}, 'accept_cookies': {'id': 'ofpnikijgfhlmmjlpkfaifhhdonchhoi', 'name': 'Accept all cookies'}, 'captcha_solver': {'id': 'hlifkpholllijblknnmbfagnkjneagid', 'name': 'CAPTCHA Solver'}, 'lean_library': {'id': 'hghakoefmnkhamdhenpbogkeopjlkpoa', 'name': 'Lean Library'}, 'popup_blocker': {'id': 'bkkbcggnhapdmkeljlodobbkopceiche', 'name': 'Pop-up Blocker'}, 'zotero_connector': {'id': 'ekhagklcjbdpajgpjgmbionohlpdbjgc', 'name': 'Zotero Connector'}}
- AVAILABLE_PROFILE_NAMES = ['system', 'extension', 'auth', 'stealth']
- __init__(profile_name, chrome_cache_dir=None, config=None)[source]
Manage a Chrome profile for browser automation.
- Parameters:
profile_name (
str) – Subdirectory underchrome_cache_dirto use as the profile.chrome_cache_dir (
Optional[Path]) – Base directory that holds profile subdirectories. Defaults to$SCITEX_BROWSER_CHROME_CACHE_DIRor$SCITEX_DIR/browser/runtime/chrome(~/.scitex/browser/runtime/chromeby default).config (
Optional[object]) – Deprecated. Back-compat shim: any object exposingget_cache_chrome_dir(profile_name) -> Pathis accepted so callers passingScholarConfigstill work. Preferchrome_cache_dir.
- check_extensions_installed(profile_dir=None, verbose=True)[source]
Check installation status of all extensions from profile directory.
- Return type:
- _get_installed_extension_paths(profile_dir)[source]
Get paths to installed extensions for –load-extension argument.
- async install_extensions_manually_if_not_installed_async(verbose=False)[source]
Open Chrome for manual extension installation.