mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-15 17:50:21 +08:00
fix new issue
This commit is contained in:
parent
b8f77474e7
commit
19ef18016a
@ -1,5 +1,4 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import List
|
|
||||||
|
|
||||||
import nodriver as webdriver
|
import nodriver as webdriver
|
||||||
from nodriver.core.element import Element
|
from nodriver.core.element import Element
|
||||||
@ -83,7 +82,7 @@ async def bypass_cloudflare(page: webdriver.Tab):
|
|||||||
|
|
||||||
elem = elem.parent
|
elem = elem.parent
|
||||||
# Get the element containing the shadow root
|
# Get the element containing the shadow root
|
||||||
for _ in range(4):
|
for _ in range(3):
|
||||||
if elem is not None:
|
if elem is not None:
|
||||||
elem = get_first_div(elem)
|
elem = get_first_div(elem)
|
||||||
else:
|
else:
|
||||||
@ -115,9 +114,10 @@ def get_first_div(elem):
|
|||||||
The first div element found, or the original element if no div is found.
|
The first div element found, or the original element if no div is found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if isinstance(elem.children, List):
|
for child in elem.children:
|
||||||
elem = next(x for x in elem.children if x.tag_name == "div")
|
if child.tag_name == "div":
|
||||||
return elem
|
return child
|
||||||
|
raise InvalidElementError
|
||||||
|
|
||||||
|
|
||||||
class InvalidElementError(Exception):
|
class InvalidElementError(Exception):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user