MeiK2333 / pyppeteer_stealth

MIT License
245 stars 53 forks source link

Under the root user of Linux, if I set --no-sandbox, stealth fails #25

Open JerryChenn07 opened 3 years ago

JerryChenn07 commented 3 years ago

Under the root user of Linux, if I set --no-sandbox, stealth fails

import asyncio

from pyppeteer import launch
from pyppeteer_stealth import stealth

async def main():
    opt = {'headless': True,'args': ['--no-sandbox']}
    browser = await launch(opt)
    page = await browser.newPage()

    await stealth(page)  # <-- Here

    await page.goto("https://bot.sannysoft.com/")
    print(await page.content())
    await browser.close()

asyncio.run(main())

result: image


But if I modify the source code of pyppeteer, write --no-sandbox directly in the DEFAULT_ARGS of the source code, it will take effect.

import asyncio

from pyppeteer import launch
from pyppeteer_stealth import stealth

async def main():
    browser = await launch(headless=True)
    page = await browser.newPage()

    await stealth(page)  # <-- Here

    await page.goto("https://bot.sannysoft.com/")
    print(await page.content())
    await browser.close()

asyncio.run(main())

image

songge8 commented 2 years ago

遇到了相同的问题