HTTP_USER_AGENT Parsing

Olly Smith oliver.smith at removethisbit.baesystems.com
Tue Jul 16 04:00:52 EDT 2002


<brueckd at tbye.com> wrote in message
news:mailman.1026755722.21116.python-list at python.org...
> On Mon, 15 Jul 2002, Olly Smith wrote:
>
> > I'm a bit of a newbie to Python, and in my quest to generate nice HTML
> > content, I need a way to work out what browsers clients are using from
their
> > HTTP_USER_AGENT strings.
> >
> > Any pointers?
>
> - Googling for lists of User Agent strings will give you sample Javascript
> to determine client platform and browser based on user agent value - this
> is pretty easy to port to Python.
>
> - The same Google search will turn up lists of known user agent strings,
> which will be useful for your test code.
>
> - User agent strings are not 100% reliable, but few people change them, so
> they are fairly accurate (you can generally even detect browsers like
> Opera, even when they are reporting themselves as IE).
>
> - Also check the HTTP spec, as it list the official format of user agent
> strings. It's basically a list of names, each followed by an optional
> version number and an optional list of additional info. On the end of the
> line can be an optional language code too, I think, e.g.  "[en]".
>
> - For most people it's not worth the effort to invest too much time doing
> browser-specific HTML. ;-)
>

Ta, I'll check that out.  This bit of code I'm working on has to produce a
'nice' interface, but part of the spec says it must work with NS4 correctly
.. and we all know NS4 is a PITA ;)

Olly






More information about the Python-list mailing list