Socket
Socket
Sign inDemoInstall

ua

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ua

User-Agent parsing and creation


Maintainers
1

ua

User-Agent parsing and creation

Installation

pip install ua

Usage

>>> import ua

Parsing

>>> user_agent = ua.parse('Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0')
>>>
>>> user_agent
UserAgent(
    products=[
        Product(name='Mozilla', version='5.0', comments=['X11', 'Linux x86_64', 'rv:88.0']),
        Product(name='Gecko', version='20100101', comments=[]),
        Product(name='Firefox', version='88.0', comments=[])
    ]
)
>>>
>>> str(user_agent)
'Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0'

Creation

>>> user_agent = ua.UserAgent(
    products=[
        ua.Product(
            name='SomeProduct',
            version='1.0',
            comments=['SomeComment']
        )
    ]
)
>>>
>>> str(user_agent)
'SomeProduct/1.0 (SomeComment)'

References

  • User agent - Wikipedia
  • User-Agent - HTTP | MDN
  • RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc