Update Phind.py

This commit is contained in:
H Lohaus 2023-11-16 18:35:22 +01:00 committed by GitHub
parent 840157abaa
commit 51a6669210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,15 +2,10 @@ from __future__ import annotations
import time import time
from urllib.parse import quote from urllib.parse import quote
try:
from selenium.webdriver.remote.webdriver import WebDriver
except ImportError:
class WebDriver():
pass
from ..typing import CreateResult, Messages from ..typing import CreateResult, Messages
from .base_provider import BaseProvider from .base_provider import BaseProvider
from .helper import format_prompt, get_browser from .helper import WebDriver, format_prompt, get_browser
class Phind(BaseProvider): class Phind(BaseProvider):
url = "https://www.phind.com" url = "https://www.phind.com"
@ -28,7 +23,7 @@ class Phind(BaseProvider):
timeout: int = 120, timeout: int = 120,
browser: WebDriver = None, browser: WebDriver = None,
creative_mode: bool = None, creative_mode: bool = None,
display: bool = True, hidden_display: bool = True,
**kwargs **kwargs
) -> CreateResult: ) -> CreateResult:
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
@ -38,7 +33,7 @@ class Phind(BaseProvider):
if browser: if browser:
driver = browser driver = browser
else: else:
if display: if hidden_display:
driver, display = get_browser("", True, proxy) driver, display = get_browser("", True, proxy)
else: else:
driver = get_browser("", False, proxy) driver = get_browser("", False, proxy)
@ -112,5 +107,5 @@ if(window.reader) {
if not browser: if not browser:
time.sleep(0.1) time.sleep(0.1)
driver.quit() driver.quit()
if display: if hidden_display:
display.stop() display.stop()