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

在 Ubuntu 16.04.6 LTS 系统上安装 Python 3.6.3

自己的阿里云一个 VPS 用的是系统 Ubuntu 16.04.6 LTS,自带的python版本是 `2.7.12` 与 `3.5.2`,有时候要用到 python `3.6`,又不想卸掉原来版本。下面介绍安装 python 3.6.3 的过程,因为版本较旧,遇到一些坑,这里记录一下。...

Leave a Comment