[Python] Nodriver Cannot Start Headless Mode

Discussão em 'Python' iniciado por Stack, Fevereiro 27, 2025.

  1. Stack

    Stack Membro Participativo

    I found Nodriver, which is the successor Undetected-Chromedriver. I am trying to run in headless mode but am having problems.

    import nodriver as uc

    async def main():
    browser = await uc.start(headless=True)
    page = await browser.get('https://bot.sannysoft.com/')

    if __name__ == '__main__':
    uc.loop().run_until_complete(main())


    However I get error

    Traceback (most recent call last):
    File "C:\no_drive_test.py", line 21, in <module>
    uc.loop().run_until_complete(main())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
    File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 721, in run_until_complete
    return future.result()
    ~~~~~~~~~~~~~^^
    File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\no_drive_test.py", line 5, in main
    browser = await uc.start(headless=True)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\nodriver\core\util.py", line 95, in start
    return await Browser.create(config)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\nodriver\core\browser.py", line 90, in create
    await instance.start()
    File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\nodriver\core\browser.py", line 393, in start
    await self.connection.send(cdp.target.set_discover_targets(discover=True))
    File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\nodriver\core\connection.py", line 413, in send
    await self._prepare_headless()
    File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python313\Lib\site-packages\nodriver\core\connection.py", line 492, in _prepare_headless
    response, error = await self._send_oneshot(
    ^^^^^^^^^^^^^^^
    TypeError: cannot unpack non-iterable NoneType object


    I tried to create issue on Nodriver github page but it looks like it's only available to collaborators of the project

    Continue reading...

Compartilhe esta Página