Package: cherry-ua-staging
Cherry UserAgent (cherry-ua)This is an advanced search and generate user agent python library, the user agents can be generated
based on various search parameters, it supports an advanced form of applying search filters.DatabaseIt usesWhatismybrowserpremiumdatabase which
consists of more than91+ Millionuser agents, which ensures everytime it generates unique random user agents.CompatibilityThe library uses as much as possible inbuilt modules, so it support all major python version.Installationpipinstallcherry-uaUsageThe simplest way to use this library is:fromcherry_uaimportUserAgentua=UserAgent()ua.get_random()To refresh the User Agent datasetua.refresh()To get the size of User Agent datasetua.size()To get specifc search filter queryua.get('device')To set specific search filter queryua.set('device','eq("mobile")')To get all the search filtersua.get_all_filters()To set multiple searcg filter queriesua.set_search_filters(device='eq("mobile")')Search FiltersTheUserAgentclass support’s multiple search parameters which can be used to get only
the user agent which satisfies your requirements. The parameters are:deviceDatatype: StringSupported Operators:eq,ne,containsDescription: This Signifies for which type of device you want user agent for.ua=UserAgent(device="eq('mobile')")# orua.set('device',"eq('mobile')")# orua.set_search_filters(device="eq('mobile')")os_nameDatatype: StringSupported Operators:eq,ne,containsDescription: This Signifies for which OS (operating system) you want user agent for.ua=UserAgent(os_name="eq('windows')")# orua.set('os_name',"eq('windows')")# orua.set_search_filters(os_name="eq('windows')")os_versionDatatype: IntegerSupported Operators:eq,lt,lte,gt,gte,neDescription: This Signifies for which OS version you want user agent for.> This is an Integer field, so it won’t take quotes inside the operator’sua=UserAgent(os_version="eq(8)")# orua.set('os_version',"eq(8)")# orua.set_search_filters(os_version="eq(8)")browserDatatype: StringSupported Operators:eq,ne,containsDescription: This Signifies for which browser you want user agent for.ua=UserAgent(browser="eq('chrome')")# orua.set('browser',"eq('chrome')")# orua.set_search_filters(browser="eq('chrome')")browser_engineDatatype: StringSupported Operators:eq,ne,containsDescription: This Signifies for which type of device you want user agent for.ua=UserAgent(browser_engine="eq('blink')")# orua.set('browser_engine',"eq('blink')")# orua.set_search_filters(browser_engine="eq('blink')")browser_versionDatatype: IntegerSupported Operators:eq,lt,lte,gt,gte,neDescription: This Signifies for which type of device you want user agent for.ua=UserAgent(browser_version="eq(90)")# orua.set('browser_version',"eq(90)")# orua.set_search_filters(browser_version="eq(90)")limitDatatype: IntegerSupported Operators:eq,lt,lte,gt,gte,neDescription: This Signifies for which type of device you want user agent for.Note: Limit should be in the range of1-10000ua=UserAgent(limit=1000)# orua.set('limit',1000)# orua.set_search_filters(limit=1000)Search Filter OperatorsTo add the support for relative searching the filter’s support some operators
just like SQL, which gives the flexibility to seearch in more customized way,
the operators it supports are:Note: More complex filter can result in less number of user agents as compared to what limit is seteqSupported datatype:String,IntegerDescription: This operator matches the exact value givenua.set('device',"eq('mobile')")# matches user agent whose device is mobileltSupported datatype:IntegerDescription: This operator matches if the value of field is less than the given valueua.set('os_version',"lt(8)")# matches user agent whose os version is less than 8gtSupported datatype:IntegerDescription: This operator matches if the value of field is greater than the given valueua.set('os_version',"gt(8)")# matches user agent whose os version is greater than 8lteSupported datatype:IntegerDescription: This operator matches if the value of field is less or equal to the given valueua.set('os_version',"lte(8)")# matches user agent whose os version is less or equal to 8gteSupported datatype:IntegerDescription: This operator matches if the value of field is greater or equal to the given valueua.set('os_version',"gte(8)")# matches user agent whose os version is greater or equal to 8neSupported datatype:String,IntegerDescription: This operator matches if the value of field is not equal to the given valueua.set('device',"ne('mobile')")# matches user agent whose device is not equal to mobilecontains(beta)Supported datatype:StringDescription: This operator matches if the field value contains the given value> This is still is beta stage, so might not work as you expectua.set('device',"eq('mobile')")# matches user agent whose device contains the word "mobile"Operator ChainingThe filter query also supports if you want to chain multiple operators, the supported
operator chaining are:andDescription: The “and” operator chains multiple operator describing as it should
matches all the operator values.ua.set('device',"ne('mobile').and.ne('pc')")# It matches user agent which has device value not equal to mobile and pc# It can also be used to chaining multiple different operatorsua.set('os_version',"gt(5).and.lt(8)")# It matches user agents which has os version greater than 5 and less than 8orDescription: The “or” operator chains multiple operator describing as it should
matches any one of the operator values.ua.set('device',"ne('mobile').or.ne('pc')")# It matches user agent which has device value not equal to mobile or pc# It can also be used to chaining multiple different operatorsua.set('os_version',"eq(5).or.gt(8)")# It matches user agents which has os version equal to 5 or greater than 8UserAgent class FunctionsFunctionParametersDescriptionReturnsget_random()Returns random user agent based on given search parameters if given.Stringrefresh()Download and loads fresh set of User agentsize()Return size of user agent downloaded datasetIntegerget()(filter_name : str)Returns value of given search parametersStringset()(filter_name : str, query : str)Sets specific given search parameterget_all_filters()Returns all the search filtersDictset_search_filters()(kwargs)Sets multiple search parametersIssuesIf facing any issues in the library usage, please feel free to raise the issue in githubissue tracker,
since i am the only sole developer of this project it might get delayed to get it resolved but i’ll
definetly try to resolve it.Donate :pray:This library itself doesn’t need much maintenance, but since i am using a premium server to ensure faster and better API
performance to search and get user agents, so i have to pay bills to keep it running, as i committed to keep it running
but with a certain limitation, which i will remove if i get enough donation to support this open source project and also
i will publish the server side code once it gets enough popularity so that others can also look into it, and may suggest some
improvements.