如何使用Flask获取用户代理? [英] How do I get the user agent with Flask?
本文介绍了如何使用Flask获取用户代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ c $>解决方案
from flask import request
request.headers.get c>
您也可以使用 request.user_agent
对象,它包含基于useragent字符串创建的以下属性:
<
== request.headers.get('User-Agent')
)I'm trying to get access to the user agent with Flask, but I either can't find the documentation on it, or it doesn't tell me.
解决方案
from flask import request
request.headers.get('User-Agent')
You can also use the request.user_agent
object which contains the following attributes which are created based on the useragent string:
- platform (windows, linux, macos, etc.)
- browser (chrome, firefox, msie, etc.)
- version
- language
- string (
== request.headers.get('User-Agent')
)
这篇关于如何使用Flask获取用户代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文