现代浏览器中的 request['HTTP_USER_AGENT'] 结构

发布于 2024-12-22 15:18:16 字数 565 浏览 1 评论 0原文

考虑到 iframe 中的 cookie 策略,我遇到了 safari 问题...我还找到了一个可行的解决方案,但为了使其工作,我需要确定用户正在查看的浏览器。

在 HTTP_USER_AGENT (django) 单词中搜索的原始解决方案 - safari。这里的问题是:

WM 用户代理上的 Safari Windows XP - Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7

Chrome Linux用户代理 - Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7(KHTML,如 Gecko) Chrome/16.0.912.63 Safari/535。

因此,我正在努力寻找有关用户代理的组成部分以及如何对其进行解析以获得精确结果的信息。当然,在这种情况下,如果没有“chrome”一词,我可以额外添加,但是 chromium konqueror 和任何其他小型浏览器呢?

I ran into a safari problem considering cookie policy in iframes... Also I found a working solution for that, yet to make it work I need to determine in what browser user is viewing.

Original solution as to search in HTTP_USER_AGENT (django) word - safari. Problem here is:

Safari Windows XP on WM User Agent - Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7

Chrome Linux User Agent - Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.

So I'm struggling to find information what makes User Agent and how to parce it to get precise results. Sure in this case I can trow in extra if there is no word 'chrome', but what about chromium konqueror and any other minor browsers...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

隔纱相望 2024-12-29 15:18:16

所以我发现在用户代理中可以有你想要的任何信息。

您可以通过某种抽象规则来确定浏览器,但这些规则并不适用于所有浏览器。

在浏览器大战期间,许多 Web 服务器被配置为仅将需要高级功能的网页发送给被识别为某个版本的 Mozilla 的客户端。
因此,大多数 Web 浏览器使用如下 User-Agent 值:Mozilla/[版本]([系统和浏览器信息])[平台]([平台详细信息])[扩展名]

更多 @ http://en.wikipedia.org/wiki/User_agent

就我而言,我已经查看了 http://www.user-agents.org/ 并确定只有 Chrome 冒充 Safari最后一节。

So I found that in User agent there can be any information you want.

There is some sort of abstract rules by witch you can determine a browser, yet those rules does not apply to all browsers.

During the browser wars, many web servers were configured to only send web pages that required advanced features to clients that were identified as some version of Mozilla.
For this reason, most Web browsers use a User-Agent value as follows: Mozilla/[version] ([system and browser information]) [platform] ([platform details]) [extensions].

More @ http://en.wikipedia.org/wiki/User_agent

In my case I've looked at http://www.user-agents.org/ and determined that only Chrome impersonates Safari in the last section.

何必那么矫情 2024-12-29 15:18:16

http://www.quirksmode.org/js/detect.html

只需搜索首先搜索 Chrome,然后搜索 Safari。

http://www.quirksmode.org/js/detect.html

Just search for the word Chrome, first, then search for Safari.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文