Skip to main content

User-Agent parsing and creation

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ua-0.1.5.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

ua-0.1.5-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page