Mobile and Tablets detection

432 views
Skip to first unread message

Marcio Andrey Oliveira

unread,
Jul 17, 2013, 2:12:47 PM7/17/13
to web...@googlegroups.com
Hi.

I'm wondering whether exists a python project that detect mobiles and tables that be as good and as up to date as http://mobiledetect.net/

Thanks.

Niphlod

unread,
Jul 17, 2013, 5:50:10 PM7/17/13
to web...@googlegroups.com
because response.user_agent doesn't work for you ?

Niphlod

unread,
Jul 17, 2013, 5:51:07 PM7/17/13
to web...@googlegroups.com
whoops. request.user_agent()

Marcio Andrey Oliveira

unread,
Jul 17, 2013, 7:06:49 PM7/17/13
to
Hi.

Thank you for replying.

I really don't know all user agents and I prefer to rely on a library that automatically detects whether the users is browsing from a regular computer, a mobile or a tablet. The greatest benefit (IMHO) from mobiledetect is that it's regularly updated to incorporate new devices.

If you take a look at mobile detect source code you will see that are around 1,300 devices up to now.

I thought I could try to convert its code from PHP to python but as I'm not that good on python I wondered if someone in python community have made a similar library / module.

Regards.

Niphlod

unread,
Jul 18, 2013, 2:13:47 AM7/18/13
to web...@googlegroups.com
ok, you're fond of that php library. But did you take a closer look to what you have right in web2py using request.user_agent() ?
web2py uses gluon/contrib/user_agent_parser.py to fill up those fields.... and it does the exact same thing!


Il giorno giovedì 18 luglio 2013 01:05:11 UTC+2, Marcio Andrey Oliveira ha scritto:
Hi.

Thank you for replying.

I really don't know all user agents and I prefer to rely on a library that automatically detects whether the users is browsing from a regular computer, a mobile or a tablet. The greatest benefit (IMHO) from mobiledetect is that it's regularly updated to incorporate new devices.

If you take a look at mobile detect source code you will see that are around 1,300 devices up to now.

I thought I could try to convert its code from PHP to python but as I'm not that good on python I wondered if someone in python community have made a similar library / module.

Regards.

On Wednesday, July 17, 2013 3:12:47 PM UTC-3, Marcio Andrey Oliveira wrote:

Angelo Compagnucci

unread,
Jul 18, 2013, 2:57:28 AM7/18/13
to web...@googlegroups.com
Hi Marcio,

I'm planning to grow the supported mobile devices list in web2py, but the support right now is fairly extensive. 
I got the user agent strings here http://www.useragentstring.com/pages/Mobile%20Browserlist/ and added at least one of the devices for each family to the unit test of gluon/contrib/user_agent_parser.py .

That class right now could discriminate between phone and tablets, so I think you can't find somany differences with http://mobiledetect.net/ .

Sincerly,

Marcio Andrey Oliveira

unread,
Jul 18, 2013, 9:43:10 AM7/18/13
to web...@googlegroups.com
Niphlod, I'm fairly new to web2py (I'm reading the official book but I'm still on page #160 of 614 pages) and I'm trying to collect the most possible information that I think relevant for what I'm planning to do.

Even if I had read entirely book I believe that not all information about web2py will be there. That's why I'm asking.

All information I gather will help me decide which framework better fits my needs.

I understood from your last email that I could call request.user_agent() and then I should figure out by myself whether it's a mobile user agent or not what I don't think feasible. The mobile detect library has methods like is_mobile(), ? and is_android() that make life easier.

Thank you for taking your time to answer my post. I really appreciate that.



Angelo, I'm glad to hear that.

Could you please show me a snippet on how to test if a browser is mobile?

Thank you a lot.

vince

unread,
Jul 18, 2013, 12:43:54 PM7/18/13
to web...@googlegroups.com
fyi request.user_agent().is_mobile will return false for ipod touch now.

Marcio Andrey Oliveira

unread,
Jul 18, 2013, 1:27:07 PM7/18/13
to web...@googlegroups.com
vince, thank you for answering me.


Regards.

On Wednesday, July 17, 2013 3:12:47 PM UTC-3, Marcio Andrey Oliveira wrote:

Niphlod

unread,
Jul 18, 2013, 8:19:59 PM7/18/13
to web...@googlegroups.com
I get the "tell me more" argument, but if you fire up web2py and just try it, you'll find those things on your own if you just use request.user_agent().
You can even find out that the scaffolding application make use of this by default inspecting request.user_agent().is_mobile flag to render a mobile-compatible menu out based on user_agent parsing.
Yep, it may be not updated in a while, but that can be easily fixed as @angelo said already in a previous post.

Christian Foster Howes

unread,
Jul 20, 2013, 12:14:17 PM7/20/13
to web...@googlegroups.com
is the WURFL library of devices more or less complete then the mobile browser list?  http://wurfl.sourceforge.net/  I used the WURFL 5-6 years ago and found it to be the most complete open-source list at the time.

Marcio Andrey Oliveira

unread,
Jul 20, 2013, 2:55:21 PM7/20/13
to web...@googlegroups.com
I have no idea how complete WURFL is but it it seems that request.user_agent()  will do the job.

Regards.

LightDot

unread,
Jul 21, 2013, 7:22:52 AM7/21/13
to web...@googlegroups.com
A quick look at WURFL - looks fine, except for the license which might be problematic for some projects - AGPL v3. They offer commercial licenses too, which might solve the problem for some.

Regards,
Ales

Andrew Rogers

unread,
Oct 3, 2020, 9:01:30 PM10/3/20
to web2py-users
Hi

I am having trouble with  detecting a mobile user when emulating an iPhone (or any of the mobile devices) in the desktop version of Chrome.  Edge seems to work fine.

request.user_agent()  gives me:
<Storage {'platform': <Storage {'name': 'Windows', 'version': '10'}>, 'os': <Storage {'name': 'Windows', 'version': '10'}>, 'bot': False, 'browser': <Storage {'name': 'Chrome', 'version': '84.0.4147.135'}>, 'is_mobile': False, 'is_tablet': False}>

request.env.http_user_agent gives me:
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1'

Is there any trick to getting that emulation working correctly in Chrome?

Andrew

FYI, this is what I get when using the emulation in Edge

request.user_agent()
<Storage {'platform': <Storage {'name': 'iOS', 'version': '13.2.3'}>, 'os': <Storage {'name': 'iOS'}>, 'bot': False, 'dist': <Storage {'name': 'iPhone', 'version': '13.2.3'}>, 'browser': <Storage {'name': 'Safari', 'version': '13.0.3'}>, 'is_mobile': True, 'is_tablet': False}>

request.env.http_user_agent
'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/85.0.4183.121'
Reply all
Reply to author
Forward
0 new messages