Skip to content

Instantly share code, notes, and snippets.

View brower-detect-4mobile-device
// use client userAagent's lowercase to match these:
Wechat: /micromessenger/,
QQBrowser: /qqbrowser/,
UC: /ubrowser|ucbrowser|ucweb/,
Shoujibaidu: /baiduboxapp|baiduhd|bidubrowser|baidubrowser/,
SamsungBrowser: /samsungbrowser/,
MiuiBrowser: /miuibrowser/,
Sogou : /sogoumobilebrowser|sogousearch/,
Explorer2345 : /2345explorer|2345chrome|mb2345browser/,
View get-spider-info.sh
#!/bin/bash
set -o nounset
set -o errexit
IFS=$'\n'
dt=$(date -d'yesterday' '+%Y%m%d') #每天读取前一天的日志
logfile="/var/log/nginx/access.log-${dt}.gz" #nginx access.log日志
#读取日志并将User Agent信息中包含爬虫标识的过滤出来进行解析操作
zcat ${logfile} | awk -F'"' 'tolower($6)~/bot|spider|yahoo! slurp/ && $2~/GET/ {print $0}' | \
@tjefferson
tjefferson / browser-detection.js
Last active Apr 27, 2022
get more precise Chinese browser information in google analytics
View browser-detection.js
<script>
var browserName = "Other";
var ua = window.navigator.userAgent;
browserRegExp = {
Sogou : /SE\s2\.X|SogouMobileBrowser/,
Explorer2345 : /2345Explorer|2345chrome|Mb2345Browser/,
Liebao : /LBBROWSER/,
Wechat : /MicroMessenger/,
QQBrowser : /QQBrowser/,
Baidu : /BIDUBrowser|baidubrowser|BaiduHD/,