(driver=None)
| 313 | |
| 314 | |
| 315 | def get_user_agent(driver=None) -> str: |
| 316 | global USER_AGENT |
| 317 | if USER_AGENT is not None: |
| 318 | return USER_AGENT |
| 319 | |
| 320 | try: |
| 321 | if driver is None: |
| 322 | driver = get_webdriver() |
| 323 | USER_AGENT = driver.execute_script("return navigator.userAgent") |
| 324 | # Fix for Chrome 117 | https://github.com/FlareSolverr/FlareSolverr/issues/910 |
| 325 | USER_AGENT = re.sub('HEADLESS', '', USER_AGENT, flags=re.IGNORECASE) |
| 326 | return USER_AGENT |
| 327 | except Exception as e: |
| 328 | raise Exception("Error getting browser User-Agent. " + str(e)) |
| 329 | finally: |
| 330 | if driver is not None: |
| 331 | if PLATFORM_VERSION == "nt": |
| 332 | driver.close() |
| 333 | driver.quit() |
| 334 | |
| 335 | |
| 336 | def start_xvfb_display(): |
nothing calls this directly
no test coverage detected