BotBrowser icon indicating copy to clipboard operation
BotBrowser copied to clipboard

When using the headful mode, results can be obtained normally, but no results are returned in headless mode. How to solve this problem?

Open dtMILKYWAY opened this issue 1 year ago • 1 comments

import asyncio import os from pathlib import Path from playwright.async_api import async_playwright

BOTBROWSER_EXEC_PATH = str(Path("./ziyuan/Chrome-bin/chrome.exe").resolve()) BOT_PROFILE_PATH = str(Path("./ziyuan/chrome137_win10_x64.enc").resolve())

if not BOTBROWSER_EXEC_PATH or not BOT_PROFILE_PATH: raise ValueError("Both BOTBROWSER_EXEC_PATH and BOT_PROFILE_PATH environment variables must be set.")

async def main(): async with async_playwright() as p: browser = await p.chromium.launch_persistent_context( user_data_dir="./user_data", executable_path=BOTBROWSER_EXEC_PATH, headless=True, # Set to True for production ignore_default_args=[ "--disable-crash-reporter", "--disable-crashpad-for-testing", "--disable-gpu-watchdog", ], args=[ "--no-sandbox", "--disable-blink-features=AutomationControlled", "--disable-audio-output", f"--bot-profile={BOT_PROFILE_PATH}", ], ) page = await browser.new_page()

    # Remove Playwright's bindings to avoid detection.
    await page.add_init_script("""
        delete window.__playwright__binding__;
        delete window.__pwInitScripts;
    """)

    await page.goto("https://bot.sannysoft.com/")
    
    
    print(await page.title())
    # await asyncio.Event().wait()

asyncio.run(main())

Results in headful mode Image

headless mode

Image

dtMILKYWAY avatar Jun 25 '25 15:06 dtMILKYWAY

Hi, if you are using demo profiles headless is not supported

MSTU0 avatar Jun 26 '25 14:06 MSTU0