mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-12-06 17:48:40 +01:00
Fix occasional headless issue on Linux when set to "false" (#1199)
* Fix occasional headless issue on Linux when set to "false" - Add a variable containing the current platform - Check if the platform is "nt" (Windows) before closing the driver * Update CHANGELOG.md --------- Co-authored-by: ilike2burnthing <59480337+ilike2burnthing@users.noreply.github.com>
This commit is contained in:
11
src/utils.py
11
src/utils.py
@@ -11,6 +11,7 @@ from selenium.webdriver.chrome.webdriver import WebDriver
|
||||
import undetected_chromedriver as uc
|
||||
|
||||
FLARESOLVERR_VERSION = None
|
||||
PLATFORM_VERSION = None
|
||||
CHROME_EXE_PATH = None
|
||||
CHROME_MAJOR_VERSION = None
|
||||
USER_AGENT = None
|
||||
@@ -38,6 +39,13 @@ def get_flaresolverr_version() -> str:
|
||||
FLARESOLVERR_VERSION = json.loads(f.read())['version']
|
||||
return FLARESOLVERR_VERSION
|
||||
|
||||
def get_current_platform() -> str:
|
||||
global PLATFORM_VERSION
|
||||
if PLATFORM_VERSION is not None:
|
||||
return PLATFORM_VERSION
|
||||
PLATFORM_VERSION = os.name
|
||||
return PLATFORM_VERSION
|
||||
|
||||
|
||||
def create_proxy_extension(proxy: dict) -> str:
|
||||
parsed_url = urllib.parse.urlparse(proxy['url'])
|
||||
@@ -314,7 +322,8 @@ def get_user_agent(driver=None) -> str:
|
||||
raise Exception("Error getting browser User-Agent. " + str(e))
|
||||
finally:
|
||||
if driver is not None:
|
||||
driver.close()
|
||||
if PLATFORM_VERSION == "nt":
|
||||
driver.close()
|
||||
driver.quit()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user