python 识别微信浏览器

用python 根据User Agent 来识别客户端是否是微信浏览器

python 识别微信浏览器

微信在 Android 下的 User Agent

1
mozilla/5.0 (linux; u; android 4.1.2; zh-cn; mi-one plus build/jzo54k) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30 micromessenger/5.0.1.352

微信在 iPhone 下的 User Agent

1
mozilla/5.0 (iphone; cpu iphone os 5_1_1 like mac os x) applewebkit/534.46 (khtml, like gecko) mobile/9b206 micromessenger/5.0

只需判断是否包含关键字 micromessenger

1
2
if 'micromessenger' in self.user_agent.lower():
    return True

本文网址: https://pylist.com/topic/133.html 转摘请注明来源

Suggested Topics

python 高效的list 去重方式

list 去重是编程中经常用到的,python 的去重方式很灵活,下面介绍多种去重方式,并比较得出最高效的方式。...

Python List 按键高效排序方法

Python含有许多古老的排序规则,这些规则在你创建定制的排序方法时会占用很多时间,而这些排序方法运行时也会拖延程序实际的运行速度。...

Leave a Comment