MobileESP: Easily detect mobile web site visitors

Script will be useful, if you want to show different version of site for desktop computers and mobile devices. Big variety of methods to detect mobile type. Avaliable in different languages, including python. The port to python was made by me with help from my freelance customer.

Here how it can be used in django project:

from mobileesp import mdetect

user_agent = request.META.get("HTTP_USER_AGENT")
http_accept = request.META.get("HTTP_ACCEPT")
if user_agent and http_accept:
    agent = mdetect.UAgentInfo(userAgent=user_agent, httpAccept=http_accept)
    #Do first! For iPhone, Android, Windows Phone 7, etc.
    if agent.detectTierIphone():
        HttpResponseRedirect('/myapp/i/')
    #Then catch all other mobile devices
    if agent.detectMobileQuick():
        HttpResponseRedirect('/myapp/m/')
#For traditional computers and tablets (iPad, Android, etc.)
return HttpResponseRedirect('/myapp/d/')

Script on code.google.com, all methods have comments with description.

Description at project site.

Published: Nov. 29, 2012
Bookmark and Share
Comments powered by Disqus