summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/you/har_file.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-05-16 20:06:57 +0200
committerGitHub <noreply@github.com>2024-05-16 20:06:57 +0200
commit0332c0c0dd01dd71aabca62f007ad9e8809ee48f (patch)
treef9a4170ef8c5b0358bc4cf7189f997e3098ee0f3 /g4f/Provider/you/har_file.py
parentUpdate README.md (diff)
parentAdd needs auth to provierds, Add PerplexityApi provider (diff)
downloadgpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar
gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.gz
gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.bz2
gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.lz
gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.xz
gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.zst
gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.zip
Diffstat (limited to 'g4f/Provider/you/har_file.py')
-rw-r--r--g4f/Provider/you/har_file.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/g4f/Provider/you/har_file.py b/g4f/Provider/you/har_file.py
index cfdca12f..969ba96c 100644
--- a/g4f/Provider/you/har_file.py
+++ b/g4f/Provider/you/har_file.py
@@ -88,36 +88,34 @@ async def get_telemetry_ids(proxy: str = None) -> list:
except NoValidHarFileError as e:
if debug.logging:
logging.error(e)
- if debug.logging:
- logging.error('Getting telemetry_id for you.com with nodriver')
+
try:
from nodriver import start
except ImportError:
raise MissingRequirementsError('Add .har file from you.com or install "nodriver" package | pip install -U nodriver')
- page = None
+ if debug.logging:
+ logging.error('Getting telemetry_id for you.com with nodriver')
+
+ browser = page = None
try:
- browser = await start()
+ browser = await start(
+ browser_args=None if proxy is None else [f"--proxy-server={proxy}"],
+ )
page = await browser.get("https://you.com")
-
while not await page.evaluate('"GetTelemetryID" in this'):
await page.sleep(1)
-
async def get_telemetry_id():
return await page.evaluate(
f'this.GetTelemetryID("{public_token}", "{telemetry_url}");',
await_promise=True
)
-
return [await get_telemetry_id()]
-
finally:
try:
if page is not None:
await page.close()
-
if browser is not None:
await browser.close()
-
except Exception as e:
if debug.logging:
logging.error(e)