Adjust the browser version in a user agent string. Args: useragent (str): The user agent string to be adjusted. browser_type (str): The type of the browser (e.g., "Firefox"). browser_version (str): The desired browser version (e.g., "92.0").
(useragent: str, browser_type: str, browser_version: str)
| 29 | |
| 30 | @staticmethod |
| 31 | def adjust_browser_version(useragent: str, browser_type: str, browser_version: str) -> str: |
| 32 | """ |
| 33 | Adjust the browser version in a user agent string. |
| 34 | |
| 35 | Args: |
| 36 | useragent (str): The user agent string to be adjusted. |
| 37 | browser_type (str): The type of the browser (e.g., "Firefox"). |
| 38 | browser_version (str): The desired browser version (e.g., "92.0"). |
| 39 | |
| 40 | Returns: |
| 41 | str: The adjusted user agent string. |
| 42 | """ |
| 43 | ua_browser_version = [word for word in useragent.split() if browser_type.capitalize() + "/" in word] |
| 44 | browser_version_list = browser_version.split(".")[:2] + ["0", "0"] |
| 45 | browser_version = ".".join(browser_version_list) |
| 46 | return useragent.replace(ua_browser_version[0], f"{browser_type}/{browser_version}") |
| 47 | |
| 48 | async def get_computer(self) -> None: |
| 49 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected