{"id":6669,"library":"httpagentparser","title":"httpagentparser","description":"httpagentparser is a Python library (current version 1.9.9) that efficiently extracts operating system, browser, and other relevant information from HTTP User-Agent strings. It offers fast parsing and is primarily focused on detecting OS and browser details rather than being a full-featured agent parser. Releases are infrequent but have recently addressed maintenance and optimization.","status":"active","version":"1.9.9","language":"en","source_language":"en","source_url":"https://github.com/shon/httpagentparser","tags":["user agent","parser","browser detection","os detection","http"],"install":[{"cmd":"pip install httpagentparser","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"httpagentparser","correct":"import httpagentparser"}],"quickstart":{"code":"import httpagentparser\n\n# Example user agent string\nuser_agent_string = \"Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.307.11 Safari/532.9\"\n\n# Basic detection returning (OS, Browser) tuple\nsimple_result = httpagentparser.simple_detect(user_agent_string)\nprint(f\"Simple Detection (OS, Browser): {simple_result}\")\n\n# Detailed detection returning a dictionary\ndetailed_result = httpagentparser.detect(user_agent_string)\nprint(f\"Detailed Detection: {detailed_result}\")\n\n# Accessing specific parts of the detailed result\nif detailed_result.get('os'):\n    print(f\"OS Name: {detailed_result['os'].get('name')}\")\nif detailed_result.get('browser'):\n    print(f\"Browser Name: {detailed_result['browser'].get('name')}\")\n    print(f\"Browser Version: {detailed_result['browser'].get('version')}\")\n\n# Example with a mobile user agent\nmobile_ua = \"Mozilla/5.0 (Linux; U; Android 2.3.5; en-in; HTC_DesireS_S510e Build/GRJ90) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1\"\nmobile_result = httpagentparser.detect(mobile_ua)\nprint(f\"\\nMobile User Agent Detailed Detection: {mobile_result}\")\nif mobile_result.get('dist'):\n    print(f\"Mobile OS Distribution: {mobile_result['dist'].get('name')} {mobile_result['dist'].get('version')}\")","lang":"python","description":"This quickstart demonstrates how to use `httpagentparser` to detect operating system and browser information from a user-agent string. It shows both the `simple_detect` method for a concise tuple output and the `detect` method for a more detailed dictionary result, including how to access specific fields like OS name and browser version."},"warnings":[{"fix":"If a predictable order is required (e.g., for logging or consistent output), process the dictionary by sorting its items before representation: `OrderedDict(sorted(httpagentparser.detect(s).items()))` (requires `collections.OrderedDict`).","message":"The `detect()` method returns a standard Python dictionary. The order of keys in dictionaries is not guaranteed across Python versions or runs, which can lead to unexpected output order if you rely on it for consistent string representation or comparison.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For highly granular device information, extensive bot detection, or parsing very obscure/malformed user-agent strings, consider alternative libraries like `ua-parser` or commercial services.","message":"The library explicitly states it 'Does not aim to be a full featured agent parser.' It is optimized for fast OS and browser detection but may not provide granular device details, comprehensive bot detection, or cover all obscure user-agent strings as thoroughly as more extensive or commercial solutions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using the latest version of `httpagentparser` (1.9.9+) and `pip` and `setuptools` are up-to-date, as recent updates aimed to 'Modernize setup' and 'Remove deprecated setuptools-tox integration.'","message":"Older versions (e.g., 1.9.5) sometimes encountered `setup.py egg_info` errors during installation in certain environments, often related to setuptools packaging issues.","severity":"gotcha","affected_versions":"<1.9.9"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}