zoukankan      html  css  js  c++  java
  • What is HTTP_USER_AGENT?

    http://perl.about.com/od/cgiprogramminginperl/a/020905.htm

    How to identify a browser

    HTTP_USER_AGENT is one of the 19 CGI environment variables defined by The National Center for Supercomputing Applications (NCSA). It is used to identify the user agent that the client is using when a CGI script is accessed from a web page.

    What is a user agent?

    A user agent is the application a client uses to access a web page, which may be a browser, a mobile device or service such as AvantGo, or web crawlers, among other things. HTTP_USER_AGENT is the CGI environment variable that is generated to identify the user agent, and this information may be used to good effect if you want to present specific pages to your users based on what they're using to view the page. It's also handy if you want to use the robots.txt file to exclude a crawler from your site, or particular sections of your site.

    What does the HTTP_USER_AGENT string look like?

    Typically, the information included in HTTP_USER_AGENT includes the name of the client application and version, the operating system used by the host, and the language. Other information may also be included, such as a URL or email address.

    Some of the strings identifying browsers are a little confusing, and this stems from the struggle for browser dominance. As one browser gains popularity, web sites may cater to it, or exclude other browsers entirely, even though they may handle complex pages being sent to it. Therefore, some browsers send a spoofed or cloaked string so that the page content will be retrieved properly.

    For example, early versions of Internet Explorer sent an HTTP_USER_AGENT string identifying it as Mozilla, which was then used by Netscape Navigator. Now that Internet Explorer has gained dominance, some newer browsers follow in the same tradition, identifying themselves as Mozilla, MSIE, and the correct browser name.

    Here are some examples
    ===
    Internet Explorer
    Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
    Mozilla/4.0 (compatible; MSIE 4.0 Crawler; Windows 95)

    Netscape Navigator
    Mozilla/4.0b1 (Win95; I)
    Mozilla/3.01Gold (Macintosh; U; PPC)
    ===

    How can I know the correct user agent?

    The easiest way to have the correct user agent at your fingertips is to use a compiled list. A good one is presented by Zytrax, and Siteware Technologies.

  • 相关阅读:
    【凸优化】【长链剖分】【2019冬令营模拟1.8】tree
    2019冬令营集训1月7-10日总结
    item()方法遍历字典
    contiue和break的用法
    内存地址与变量值的关系
    Python垃圾回收机制
    Python的小整数池
    常量的命名和注意事项
    基本运算符
    Python中最简单快捷的输出方式
  • 原文地址:https://www.cnblogs.com/ctoroad/p/285745.html
Copyright © 2011-2022 走看看