{"library":"pymobiledetect","title":"PyMobileDetect","description":"PyMobileDetect is a Python library that detects mobile and tablet browsers based on the User-Agent string. It is a port of the popular PHP Mobile Detect library. The current version is 1.3.2, with releases being infrequent but stable, primarily aligning with updates to the underlying detection rules.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pymobiledetect"],"cli":null},"imports":["from mobiledetect import MobileDetect"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from mobiledetect import MobileDetect\n\n# Simulate a User-Agent string (e.g., from an HTTP request header)\n# In a web framework, you would get this from request.headers.get('User-Agent', '')\nuser_agent = 'Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Mobile Safari/537.36'\n\ndetector = MobileDetect(user_agent=user_agent)\n\nif detector.is_mobile():\n    print(\"This is a mobile device.\")\nelif detector.is_tablet():\n    print(\"This is a tablet device.\")\nelse:\n    print(\"This is a desktop device.\")\n\n# Check for specific properties\nif detector.is_android():\n    print(\"Operating system: Android\")\nif detector.is_chrome():\n    print(\"Browser: Chrome\")\n","lang":"python","description":"Initialize MobileDetect with a User-Agent string and use its methods to check device type and properties. The User-Agent string is crucial for correct detection.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}