MCPcopy
hub / github.com/FlareSolverr/FlareSolverr / get_user_agent

Function get_user_agent

src/utils.py:315–333  ·  view source on GitHub ↗
(driver=None)

Source from the content-addressed store, hash-verified

313
314
315def 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
336def start_xvfb_display():

Callers

nothing calls this directly

Calls 2

get_webdriverFunction · 0.85
quitMethod · 0.80

Tested by

no test coverage detected