window.navigator.userAgent
1) Chrome
Win7:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1
2) Firefox
Win7:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0
3) Safari
Win7:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50
4) Opera
Win7:
Opera/9.80 (Windows NT 6.1; U; zh-cn) Presto/2.9.168 Version/11.50
5) IE
Win7+ie9:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; Tablet PC 2.0; .NET4.0E)
Win7+ie8:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)
WinXP+ie8:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.0)
WinXP+ie7:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
WinXP+ie6:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
6) 傲游
傲游3.1.7在Win7+ie9,高速模式:
Mozilla/5.0 (Windows; U; Windows NT 6.1; ) AppleWebKit/534.12 (KHTML, like Gecko) Maxthon/3.0 Safari/534.12
傲游3.1.7在Win7+ie9,IE內(nèi)核兼容模式:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
7) 搜狗
搜狗3.0在Win7+ie9,IE內(nèi)核兼容模式:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; SE 2.X MetaSr 1.0)
搜狗3.0在Win7+ie9,高速模式:
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.33 Safari/534.3 SE 2.X MetaSr 1.0
8) 360
360瀏覽器3.0在Win7+ie9:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
9) QQ瀏覽器
QQ瀏覽器6.9(11079)在Win7+ie9,極速模式:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1 QQBrowser/6.9.11079.201
QQ瀏覽器6.9(11079)在Win7+ie9,IE內(nèi)核兼容模式:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E) QQBrowser/6.9.11079.201
10) 阿云瀏覽器
阿云瀏覽器1.3.0.1724 Beta(編譯日期2011-12-05)在Win7+ie9:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
一個隨機切換user_agent的第三方python庫:my_fake_useragent
安裝 pip install?my_fake_useragent
# -*- coding: utf-8 -*-
import my_fake_useragent as ua
if __name__ == '__main__':
? ? user_agent = ua.UserAgent()
? ? # 方法1
? ? # 隨機獲取一個user-agent,每次獲取的都不一樣
? ? for _ in range(10):
? ? ? ? print(user_agent.random())
? ? # 方法2
? ? # user_agent.get_useragent_list(): 返回一個user-agent的列表
? ? for index, each_useragent in enumerate(user_agent.get_useragent_list()):
? ? ? ? print(index, ': ', each_useragent)
useragent?中文名為用戶代理(區(qū)別于爬蟲時使用的代理ip),簡稱UA,是一個特殊字符串頭,使得服務(wù)器能夠識別客戶使用的操系統(tǒng)及版本、CPU類型、瀏覽器及版本、瀏覽器渲染引擎、瀏覽器語言等。
一些網(wǎng)站常常通過 UA 來給不同的操作系統(tǒng)、不同的瀏覽器發(fā)送不同的頁面。
UA字串的標(biāo)準(zhǔn)格式:
瀏覽器標(biāo)識(操作系統(tǒng)標(biāo)識;加密等級標(biāo)識;瀏覽器語言)渲染引擎標(biāo)識 版本信息
下面列舉 UA 中包含的字符串信息
操作系統(tǒng)標(biāo)識
FreeBSD
X11; FreeBSD (version no.) i386
X11; FreeBSD (version no.) AMD64
Linux
X11; Linux ppc
X11; Linux ppc64
X11; Linux i686
X11; Linux x86_64
Mac
Macintosh; PPC Mac OS X
Macintosh; Intel Mac OS X
Solaris
X11; SunOS i86pc
X11; SunOS sun4u
Windows:
Windows NT 10.0 對應(yīng)操作系統(tǒng)windows 10
windows NT 6.2 對應(yīng)操作系統(tǒng) windows 8
Windows NT 6.1 對應(yīng)操作系統(tǒng) windows 7
Windows NT 6.0 對應(yīng)操作系統(tǒng) windows vista
Windows NT 5.2 對應(yīng)操作系統(tǒng) windows 2003
Windows NT 5.1 對應(yīng)操作系統(tǒng) windows xp
Windows NT 5.0 對應(yīng)操作系統(tǒng) windows 2000
Windows ME
Windows 98
加密等級標(biāo)識
N: 表示無安全加密
I: 表示弱安全加密
U: 表示強安全加密
瀏覽器語言
在首選項 > 常規(guī) > 語言中指定的語言
渲染引擎
瀏覽器 使用 Presto 渲染引擎,格式為: Presto/版本號
版本信息
顯示 瀏覽器 真實版本信息,格式為: Version/版本號