本文整理匯總了Python中werkzeug.useragents.UserAgent方法的典型用法代碼示例。如果您正苦於以下問題:Python useragents.UserAgent方法的具體用法?Python useragents.UserAgent怎麽用?Python useragents.UserAgent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類werkzeug.useragents
的用法示例。
在下文中一共展示了useragents.UserAgent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_email_view
# 需要導入模塊: from werkzeug import useragents [as 別名]
# 或者: from werkzeug.useragents import UserAgent [as 別名]
def get_email_view(self):
@self.jinja2_view('email_error.html')
def error_email(params):
ua = UserAgent(params.get('ua'))
if ua.browser:
browser = '{0} {1} {2} {3}'
lang = ua.language or ''
browser = browser.format(ua.platform, ua.browser,
ua.version, lang)
params['browser'] = browser
else:
params['browser'] = ua.string
params['time'] = params['time'][:19]
return params
return error_email
# ============================================================================
示例2: user_agent
# 需要導入模塊: from werkzeug import useragents [as 別名]
# 或者: from werkzeug.useragents import UserAgent [as 別名]
def user_agent(self):
"""The current user agent."""
from werkzeug.useragents import UserAgent
return UserAgent(self.environ)
示例3: __call__
# 需要導入模塊: from werkzeug import useragents [as 別名]
# 或者: from werkzeug.useragents import UserAgent [as 別名]
def __call__(self, environ, start_response):
ua = UserAgent(environ)
if ua.browser != 'msie':
return self.app(environ, start_response)
return self.run_fixed(environ, start_response)
示例4: parse_browser
# 需要導入模塊: from werkzeug import useragents [as 別名]
# 或者: from werkzeug.useragents import UserAgent [as 別名]
def parse_browser(self, params):
ua = UserAgent(params.get('ua'))
if ua.browser:
params['ua_platform'] = ua.platform
params['ua_browser'] = ua.browser
params['ua_version'] = ua.version
else:
params['ua_platform'] = '-'
params['ua_browser'] = params.get('ua', '-')
params['ua_version'] = '-'