Grabbing user's agent and OS type

Ben Finney ben+python at benfinney.id.au
Sun Mar 13 21:01:41 EDT 2011


Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:

> I think you give the user-agent string too much credit. Despite what
> some people think, including some browser developers, it's a free-form
> string and can contain anything the browser wants. There's no
> guarantee that fields will appear in a particular order, or even
> appear at all.

Much more importantly: due to a long history of abuse by web application
developers, the User-Agent field is often *deliberately faked* in the
web client to report false information in order to get past design flaws
in web applications.

Some of us do this in a systematic way to send a meaningful message to
the people misusing this field.

    <URL:http://linuxmafia.com/faq/Web/user-agent-string.html>

> If you're doing feature detection by parsing the UA string, you're in
> a state of sin.

Word.

There are some plausible uses of the User-Agent field that are not
necessarily abusive, but you can thank the past and present hordes of
abusive applications for poisoning the well and making it a pretty
useless field now.

-- 
 \         “What you have become is the price you paid to get what you |
  `\                                 used to want.” —Mignon McLaughlin |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list