Determine from a HTTP request if the user is on a Smart Phone, IE, Firefox

Ben Finney ben+python at
Tue Feb 1 02:53:35 CET 2011

Sascha <samzielkeryner at> writes:

> I am returning specialised website html according to what platform the
> user is on. Is there a way to determine if the user is on a Smart
> Phone or on IE or on Firefox?

The HTTP standard defines the “User-Agent” field, to be sent as part of
the request header <URL:>.

Note that this information is often abused by web server operators, and
the response of many users is to mangle or fabricate this field before
it is sent to the server. (My browser, for example, instructs the reader
to stop obsessing about User-Agent and to code for web standards instead

 \           “If you do not trust the source do not use this program.” |
  `\                                —Microsoft Vista security dialogue |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list