Загрузка...

With headless the captcha appears, without it it doesn’t and everything is ok

Thread in Python created by Tensor Saturday at 4:21 PM. 159 views

  1. Tensor
    Tensor Topic starter Saturday at 4:21 PM 1,118 Aug 14, 2021
    Python
        def _sync_get_cookies(
    self,
    # proxy: str | None = None
    ) -> None:
    options = Options()

    options.add_argument("--headless=new")
    options.add_argument("--disable-blink-features=AutomationControlled")
    options.add_argument("--no-sandbox")
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("--ignore-certificate-errors")
    options.add_argument("--allow-insecure-localhost")
    options.add_argument("--window-size=1920,1080")
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option("useAutomationExtension", False)

    options.add_argument(f"user-agent={self.headers['user-agent']}")

    browser: Chrome = Chrome(options=options, service=Service(log_path=os.devnull))

    stealth(
    browser,
    user_agent=self.headers["user-agent"],
    languages=["ru-RU", "ru"], # type: ignore
    vendor = "Google Inc.",
    platform="Win32",
    webgl_vendor="Intel Inc.",
    renderer="Intel Iris OpenGL Engine",
    fix_hairline=True,
    run_on_insecure_origins=True,
    )

    try:
    browser.get(self.RAS_URL)

    time.sleep(random.uniform(5, 10))

    browser.execute_script(
    "document.querySelector('#b-form-submit > div > button').click()"
    )

    time.sleep(random.uniform(5, 10))

    cookies = browser.get_cookies()
    self.cookies = cookies_to_header(cookies)

    finally:
    browser.quit()
    С headless — вылазит капча, без — не вылазит и всё ок

    Как обойти?
     
    1. modafinil
      avatarTensor, ну так понятно что на калселениуме будет капчу выдавать тебе
    2. Tensor Topic starter
      avatarmodafinil, ага, на playwright в целом не ворк
  2. жди
    patchright использовать
     
    1. View previous comments (6)
    2. Yandex
      avatarTensor, используешь --headless=new ? Без него будет детектить.
    3. Tensor Topic starter
      avatarYandex, пробовал, тоже самое
    4. Yandex
      avatarTensor, Скинь сайт где проверяешь, и код. Без Headless есть капча?
  3. ilyxa05
    ilyxa05 Sunday at 2:38 AM
    Temporary file hosting
    1,199 Jul 17, 2022
    смотря какая капча, попробуй использовать camoufox
     
Loading...