Skip to content

tombulled/ua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

User-Agent parsing and creation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages