是否可以按设备类型自动对用户代理进行分类?

时间:2018-09-18 11:52:27

标签: r user-agent

我已经从数据集中提取了一些用户代理指标,但是我想知道是否有一种方法可以对这些指标进行分类。

具体来说,我想知道有多少用户在使用

  • 移动
  • 桌面
  • 平板电脑

我当然可以手动查看其中一个指标(例如os.family)并以这种方式对其进行分类,但是效率不高,我想使它自动化。

此外,似乎还没有确定设备是否为平板电脑的方法(据我所知,没有针对平板电脑的操作系统);如果无法实现,那么我很高兴将tablet归入mobile类别,因为按定义,平板电脑确实是移动设备。

目前,我正在使用uaparserjs软件包,因为它看起来相对比较好,但是缺少分类。

有没有办法做到这一点?

如果其他建议或建议被证明是我目前正在使用的更好的解决方案,我也愿意接受。

以下是提取的用户代理数据的前20行:

ua <- structure(list(userAgent = c("Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) GSA/23.1.148956103 Mobile/14D27 Safari/600.1.4", 
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", 
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1", 
"Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; rv:11.0) like Gecko", 
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36", 
"Mozilla/5.0 (X11; CrOS x86_64 9000.82.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", 
"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko", 
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14A403 Safari/602.1", 
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36", 
"Mozilla/5.0 (Linux; Android 7.1.2; Nexus 5X Build/N2G47Z) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36", 
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.0 Mobile/14F89 Safari/602.1", 
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.0 Mobile/14G60 Safari/602.1", 
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.0 Mobile/14F89 Safari/602.1", 
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.0 Mobile/14G60 Safari/602.1", 
"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36", 
"Mozilla/5.0 (Linux; Android 4.2.2; GT-I9195 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.89 Mobile Safari/537.36", 
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.0 Mobile/14G60 Safari/602.1", 
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.0 Mobile/14G60 Safari/602.1", 
"Mozilla/5.0 (Linux; Android 5.1.1; SM-J320F Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.107 Mobile Safari/537.36", 
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36"
), ua.family = c("Mobile Safari", "Chrome", "Mobile Safari", 
"IE", "Chrome", "Chrome", "IE", "Mobile Safari", "Chrome", "Chrome Mobile", 
"Mobile Safari", "Mobile Safari", "Mobile Safari", "Mobile Safari", 
"Chrome", "Chrome Mobile", "Mobile Safari", "Mobile Safari", 
"Chrome Mobile", "Chrome"), ua.major = c("10", "56", "10", "11", 
"58", "56", "11", "10", "59", "59", "10", "10", "10", "10", "60", 
"50", "10", "10", "60", "61"), ua.minor = c("2", "0", "0", "0", 
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 
"0", "0", "0"), ua.patch = c("1", "2924", NA, NA, "3029", "2924", 
NA, NA, "3071", "3071", NA, NA, NA, NA, "3112", "2661", NA, NA, 
"3112", "3163"), os.family = c("iOS", "Windows 8.1", "iOS", "Windows 8.1", 
"Windows 7", "Chrome OS", "Windows 7", "iOS", "Windows 10", "Android", 
"iOS", "iOS", "iOS", "iOS", "Windows 8", "Android", "iOS", "iOS", 
"Android", "Windows 10"), os.major = c("10", NA, "10", NA, NA, 
"9000", NA, "10", NA, "7", "10", "10", "10", "10", NA, "4", "10", 
"10", "5", NA), os.minor = c("2", NA, "2", NA, NA, "82", NA, 
"0", NA, "1", "3", "3", "3", "3", NA, "2", "3", "3", "1", NA), 
    os.patch = c("1", NA, "1", NA, NA, "0", NA, "1", NA, "2", 
    "2", "3", "2", "3", NA, "2", "3", "3", "1", NA), device.family = c("iPhone", 
    "Other", "iPhone", "Other", "Other", "Other", "Other", "iPhone", 
    "Other", "Nexus 5X", "iPhone", "iPhone", "iPhone", "iPhone", 
    "Other", "Samsung GT-I9195", "iPhone", "iPhone", "Samsung SM-J320F", 
    "Other"), device.brand = c("Apple", NA, "Apple", NA, NA, 
    NA, NA, "Apple", NA, "LG", "Apple", "Apple", "Apple", "Apple", 
    NA, "Samsung", "Apple", "Apple", "Samsung", NA), device.model = c("iPhone", 
    NA, "iPhone", NA, NA, NA, NA, "iPhone", NA, "Nexus 5X", "iPhone", 
    "iPhone", "iPhone", "iPhone", NA, "GT-I9195", "iPhone", "iPhone", 
    "SM-J320F", NA)), row.names = c(NA, -20L), class = c("tbl_df", 
"tbl", "data.frame"))

0 个答案:

没有答案