通过浏览器查找设备

时间:2016-05-24 21:27:16

标签: device

使用formstack,他们会在每个表单提交时记录浏览器。从此我想揭示该设备,无论是台式机,平板电脑还是移动设备。有没有可以解码的数据库?我有317种不同的浏览器,如下所示:

Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36

Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; MAARJS; rv:11.0) like Gecko

Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) 

Chrome/47.0.2526.106 Safari/537.36

Chrome 47.0.2526.106 / Windows

IE 10.0 / Windows 8

Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) 

Chrome/47.0.2526.106 Safari/537.36 OPR/34.0.2036.47

1 个答案:

答案 0 :(得分:0)

UserAgentString.com有一个用户代理字符串列表,它似乎相当全面,并且还提供RESTful API。 这应该可以帮助您自动解码字符串。

如果您使用的是 JavaScript ,还有have a look at UAParser.js

var result = UAParser('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2');

console.log(result.browser);          // {name: "Chromium", version: "15.0.874.106"}
console.log(result.device);           // {model: undefined, type: undefined, vendor: undefined}
console.log(result.os);               // {name: "Ubuntu", version: "11.10"}
console.log(result.os.version);       // "11.10"
console.log(result.engine.name);      // "WebKit"
console.log(result.cpu.architecture); // "amd64"

对于 PHP the function get_browser()可以帮助您:

<?php
echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";

$browser = get_browser(null, true);
print_r($browser);
?>

---------------------

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3

Array
(
    [browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$
    [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*
    [parent] => Firefox 0.9
    [platform] => WinXP
    [browser] => Firefox
    [version] => 0.9
    ....
}