scitex_browser.stealth

Stealth and anti-detection components.

class scitex_browser.stealth.StealthManager(viewport_size=None, spoof_dimension=False)[source]

Bases: object

__init__(viewport_size=None, spoof_dimension=False)[source]
get_random_user_agent()[source]
Return type:

str

get_random_viewport()[source]
Return type:

dict

get_stealth_options()[source]
Return type:

dict

get_stealth_options_additional()[source]
Return type:

list

get_network_evasion_headers()[source]

Generate realistic HTTP headers to avoid network-level detection.

Return type:

dict

async add_human_behavior_async(page)[source]

Add human-like behavior patterns to avoid detection.

async handle_cloudflare_challenge_async(page, max_wait=45)[source]

Enhanced Cloudflare challenge detection and handling.

get_init_script()[source]
Return type:

str

get_dimension_spoofing_script()[source]

Generate comprehensive JavaScript dimension spoofing script for invisible browser mode.

This creates a dual-layer window configuration: - Physical window: 1x1 pixel (invisible to user) - Reported dimensions: 1920x1080 (natural desktop size for bot detection)

The script is bulletproof and handles all dimension-related APIs that bot detectors commonly check.

Return type:

str

async human_delay_async(min_ms=1000, max_ms=3000)[source]
async human_click_async(page, element)[source]
async human_mouse_move_async(page)[source]
async human_scroll_async(page)[source]
async human_type_async(page, selector, text)[source]
class scitex_browser.stealth.HumanBehavior[source]

Bases: object

Simulates human-like behavior patterns for browser automation.

__init__()[source]
async random_delay_async(min_ms=1000, max_ms=3000, page=None)[source]

Add random delay to simulate human timing.

Return type:

None

async reading_delay_async(content_length=1000, page=None)[source]

Simulate time taken to read content based on length.

Return type:

None

async mouse_move_async(page, x=None, y=None)[source]

Move mouse to position with human-like movement.

Return type:

None

async hover_and_click_async(page, selector=None, element=None)[source]

Hover over element before clicking with human-like timing.

Return type:

None

async scroll_async(page, direction='down', distance=None)[source]

Scroll page with human-like behavior.

Return type:

None

async static type_text_async(page, selector=None, element=None, text='', clear_first=False)[source]

Type text with human-like timing and occasional mistakes.

Return type:

None

async static random_mouse_movement_async(page)[source]

Perform random mouse movements to appear active.

Return type:

None

async static pdf_viewing_behavior_async(page)[source]

Simulate human behavior when viewing a PDF.

Return type:

None

async static wait_for_download_async(page)[source]

Wait for download with human-like patience.

Return type:

None

async static form_interaction_async(page)[source]

Simulate human interaction with forms.

Return type:

None