How to use the pyppeteer.launcher.Launcher function in pyppeteer

To help you get started, we’ve selected a few pyppeteer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github miyakogi / pyppeteer / tests / test_launcher.py View on Github external
def test_user_data_dir(self):
        launcher = Launcher({'args': ['--user-data-dir=/path/to/profile']})
        self.check_default_args(launcher)
        self.assertIn('--user-data-dir=/path/to/profile',
                      launcher.chromeArguments)
        self.assertIsNone(launcher.temporaryUserDataDir)
github miyakogi / pyppeteer / tests / test_launcher.py View on Github external
def test_args(self):
        launcher = Launcher({'args': ['--some-args']})
        self.check_default_args(launcher)
        self.assertIn('--some-args', launcher.chromeArguments)
github miyakogi / pyppeteer / tests / test_launcher.py View on Github external
def test_disable_headless(self):
        launcher = Launcher({'headless': False})
        for opt in self.headless_options:
            self.assertNotIn(opt, launcher.chromeArguments)
github miyakogi / pyppeteer / tests / test_launcher.py View on Github external
def test_executable(self):
        launcher = Launcher({'executablePath': '/path/to/chrome'})
        self.assertEqual(launcher.chromeExecutable, '/path/to/chrome')
github miyakogi / pyppeteer / tests / test_launcher.py View on Github external
def test_filter_ignore_default_args(self):
        _defaultArgs = defaultArgs()
        options = deepcopy(DEFAULT_OPTIONS)
        launcher = Launcher(
            options,
            # ignore first and third default arguments
            ignoreDefaultArgs=[_defaultArgs[0], _defaultArgs[2]],
        )
        self.assertNotIn(_defaultArgs[0], launcher.cmd)
        self.assertIn(_defaultArgs[1], launcher.cmd)
        self.assertNotIn(_defaultArgs[2], launcher.cmd)
github miyakogi / pyppeteer / tests / test_launcher.py View on Github external
def test_disable_default_args(self):
        launcher = Launcher(ignoreDefaultArgs=True)
        # check default args
        self.assertNotIn('--no-first-run', launcher.chromeArguments)
        # check automation args
        self.assertNotIn('--enable-automation', launcher.chromeArguments)
github piontas / python-aada / aada / launcher.py View on Github external
import asyncio
import logging
from typing import Any, Dict, List, TYPE_CHECKING

from pyppeteer.launcher import Launcher, DEFAULT_ARGS, AUTOMATION_ARGS
from pyppeteer.browser import Browser
from pyppeteer.util import check_chromium, chromium_executable
from pyppeteer.util import download_chromium, merge_dict, get_free_port

if TYPE_CHECKING:
    from typing import Optional


class HeadLessLauncher(Launcher):
    """Chromium parocess launcher class."""

    def __init__(self, options: Dict[str, Any] = None, **kwargs: Any) -> None:
        """Make new launcher."""
        self.options = merge_dict(options, kwargs)
        self.port = get_free_port()
        self.url = f'http://127.0.0.1:{self.port}'
        self.chrome_args: List[str] = []
        self._loop = self.options.get('loop', asyncio.get_event_loop())

        log_level = self.options.get('logLevel')
        if log_level:
            logging.getLogger('pyppeteer').setLevel(log_level)

        if not self.options.get('ignoreDefaultArgs', False):
            self.chrome_args.extend(DEFAULT_ARGS)
github mikeyy / nonoCAPTCHA / solver.py View on Github external
import util
from config import settings
from helper import wait_between
from speech import get_text


FORMAT = '%(asctime)s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger(__name__)
if settings["debug"]:
    logger.setLevel('DEBUG')



class Launcher(launcher.Launcher):
    async def launch(self):
        self.chromeClosed = False
        self.connection: Optional[Connection] = None
        env = self.options.get('env')
        self.proc = await asyncio.subprocess.create_subprocess_exec(
            *self.cmd,
            stdout=asyncio.subprocess.DEVNULL,
            stderr=asyncio.subprocess.DEVNULL,
            env=env,
        )

        def _close_process(*args, **kwargs):
            if not self.chromeClosed:
                asyncio.get_event_loop().run_until_complete(self.killChrome())

        # dont forget to close browser process
github mikeyy / nonoCAPTCHA / nonoCAPTCHA / solver.py View on Github external
from async_timeout import timeout as async_timeout

from nonoCAPTCHA import util
from nonoCAPTCHA.helper import wait_between
from nonoCAPTCHA.speech import get_text
from config import settings


FORMAT = "%(asctime)s %(message)s"
logging.basicConfig(format=FORMAT)
logger = logging.getLogger(__name__)
if settings["debug"]:
    logger.setLevel("DEBUG")


class Launcher(launcher.Launcher):
    async def launch(self):
        self.chromeClosed = False
        self.connection: Optional[Connection] = None
        env = self.options.get("env")
        self.proc = await asyncio.subprocess.create_subprocess_exec(
            *self.cmd,
            stdout=asyncio.subprocess.DEVNULL,
            stderr=asyncio.subprocess.DEVNULL,
            env=env,
        )

        def _close_process(*args, **kwargs):
            if not self.chromeClosed:
                asyncio.get_event_loop().run_until_complete(self.killChrome())

        # dont forget to close browser process
github mikeyy / nonoCAPTCHA / nonocaptcha / launcher.py View on Github external
import json
import logging
import os

from urllib.request import urlopen
from urllib.error import URLError

from pyppeteer import launcher
from pyppeteer.browser import Browser
from pyppeteer.connection import Connection
from pyppeteer.errors import BrowserError
from pyppeteer.util import check_chromium, chromium_executable
from pyppeteer.util import download_chromium, merge_dict, get_free_port


class Launcher(launcher.Launcher):
    """Chrome parocess launcher class."""

    def __init__(self, options,  # noqa: C901
                 **kwargs) -> None:
        """Make new launcher."""
        self.options = merge_dict(options, kwargs)
        self.port = get_free_port()
        self.url = f'http://127.0.0.1:{self.port}'
        self.chrome_args = [f'--remote-debugging-port={self.port}']
        self._loop = self.options.get('loop', asyncio.get_event_loop())

        logLevel = self.options.get('logLevel')
        if logLevel:
            logging.getLogger('pyppeteer').setLevel(logLevel)
        self.chromeClosed = True
        if self.options.get('appMode', False):