From 19ef18016a705356f7c7f5616c48c0715ad3987b Mon Sep 17 00:00:00 2001 From: Thephaseless Date: Fri, 13 Sep 2024 18:04:22 +0000 Subject: [PATCH] fix new issue --- src/utils/browser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/browser.py b/src/utils/browser.py index ee2b7a2..1f696b6 100644 --- a/src/utils/browser.py +++ b/src/utils/browser.py @@ -1,5 +1,4 @@ import asyncio -from typing import List import nodriver as webdriver from nodriver.core.element import Element @@ -83,7 +82,7 @@ async def bypass_cloudflare(page: webdriver.Tab): elem = elem.parent # Get the element containing the shadow root - for _ in range(4): + for _ in range(3): if elem is not None: elem = get_first_div(elem) else: @@ -115,9 +114,10 @@ def get_first_div(elem): The first div element found, or the original element if no div is found. """ - if isinstance(elem.children, List): - elem = next(x for x in elem.children if x.tag_name == "div") - return elem + for child in elem.children: + if child.tag_name == "div": + return child + raise InvalidElementError class InvalidElementError(Exception):